Skip to content

Instantly share code, notes, and snippets.

@pcreux
Created December 17, 2010 19:17
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 pcreux/745532 to your computer and use it in GitHub Desktop.
Save pcreux/745532 to your computer and use it in GitHub Desktop.
operator priorities
def a
puts 'a'
'a'
end
def null
puts 'null'
nil
end
def memoize_1
@@memoize_1 ||= null or a
end
def memoize_2
@@memoize_2 ||= null || a
end
puts "== memoize_1"
3.times do
memoize_1
end
puts "== memoize_2"
3.times do
memoize_2
end
# == memoize_1
# null
# a
# null
# a
# null
# a
# == memoize_2
# null
# a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment