News for hackers. Stuff that matters.
Re:Moment of Ruby: An Argument for Nothing by zemptime on Friday November 06, 2026 @12:00PM (#50394989)
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?

There are no comments on this comment yet.