Agreed. Ruby is a very sharp tool and its expressiveness can lead to overly clever expressions of creativity.
Better to use `defined?` keyword for nil checking. It does what it says on the box.
Better to use `defined?` keyword for nil checking. It does what it says on the box.
irb(main):020\* def cloaking(value = nil)
irb(main):021\* if defined?(value)
irb(main):022\* @value = value
irb(main):023\* else
irb(main):024\* @value
irb(main):025\* end
irb(main):026> end
=> :cloaking
irb(main):027> cloaking("on")
=> "on"
irb(main):028> cloaking()
=> nil
irb(main):029> cloaking("on")
=> "on"
irb(main):030> cloaking
=> nil
calling cloaking with no argument clears the value this method is intended to read. could `defined?` be used to accomplish this in some way I didn't demonstrate here?