Skip to content

Instantly share code, notes, and snippets.

@JEG2
Created January 11, 2016 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JEG2/977d7c287a566b24497a to your computer and use it in GitHub Desktop.
Save JEG2/977d7c287a566b24497a to your computer and use it in GitHub Desktop.
You can call methods higher than their definitions, as long as it's executed before said call.
>> class Magic
>> def initialize
>> self.var = 42
>> puts var
>> end
>> attr_accessor :var
>> end
=> nil
>> Magic.new
42
=> #<Magic:0x007ff9eb8bf398 @var=42>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment