Hacker News new | ask | show | jobs
by Mon_Ouie 4893 days ago
Methods that simply behave differently depending on whether or not an argument is given. For example, passing nil (or any other object) to inject is different from passing nothing.

     [1, 2, 3].inject(:+)
     [1, 2, 3].inject(0, :+)
     [1, 2, 3].inject(nil, :+) # doesn't work
Rubinius uses a magic ``undefined`` value for this:

     def inject(initial=undefined, sym=undefined, &block)