Created
August 2, 2012 14:23
-
-
Save carvil/3237436 to your computer and use it in GitHub Desktop.
Initialise only once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bla | |
attr_accessor :my_time | |
def my_time | |
@my_time ||= Time.now.to_i + 100 | |
end | |
end | |
[2] pry(main)> b = Bla.new | |
=> #<Bla:0x007f9b4d8660b0> | |
[3] pry(main)> b.my_time | |
=> 1343917475 | |
[4] pry(main)> b.my_time | |
=> 1343917475 | |
[5] pry(main)> b.my_time | |
=> 1343917475 | |
[6] pry(main)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need your Clojure XML! Can I swap it for some Ruby, please?