Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

Интересное использование default params

// http://blog.floehopper.org/presentations/lrug-mock-objects-2007-07-09/
# def started?(clock = Clock.new)

class Clock
  def time
    Time.now
  end
end

class Event
  def initialize(start_time)
    @start_time = start_time
  end
  
  def started?(clock = Clock.new)
    clock.time > @start_time
  end  
end
« Newer Snippets
Older Snippets »
1 total  XML / RSS feed