Not totally following this one. If the contract of your methods needs to differentiate an actually supplied "nil" from "nothing was supplied", how does `defined?` accomplish that? For ex, using it would break the intended contract here:
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?
Had a difficult time trying to think of a good example, and settled on "legacy config code whose contract you absolutely can't change for " + "spaceships."
reply