Skip to content

Instantly share code, notes, and snippets.

@buth
Created August 10, 2014 16:49
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 buth/1b790c3435387e725d3c to your computer and use it in GitHub Desktop.
Save buth/1b790c3435387e725d3c to your computer and use it in GitHub Desktop.
Ruby class variables
module M
def value
@@value ||= rand(100)
end
end
class A
include M
end
class B
include M
end
a = A.new
b = B.new
puts "#{a.value} == #{b.value}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment