News for hackers. Stuff that matters.
Re:Avoid Null Checks by Replacing Finders with Tellers by dragonwriter on Monday June 17, 2013 @06:44PM (#5896464)
To illustrate that this is not iteration, assuming the existence of a DataSource class with a private find_person(id) finder that returns either a person object or nil, the method being called here could be implemented thusly:

  class DataSource

    def person(id)
      p = find_person(id)
      p && yield p
    end

  end

There are no comments on this comment yet.