Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Dog
- def speak
- woof
- end
- end
- def woof
- if @dog_generic == nil
- puts "@dog_generic isn't scoped when .woof is called from a class method!\n"
- else
- puts "@dog_generic is scoped when .woof is called from the global scope. See:\n" + @dog_generic
- end
- end
- @dog_generic = "Woof!"
- lassie = Dog.new
- lassie.speak #=> @dog_generic isn't scoped when .woof is called from a class method!\n
- woof #=> @dog_generic is scoped when .woof is called from the global scope. See:\nWoof!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement