Skip to content

Instantly share code, notes, and snippets.

@yxhuvud

yxhuvud/||= Secret

Created July 1, 2018 19:45
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 yxhuvud/f9fc14095b07ce33f2650a592757d307 to your computer and use it in GitHub Desktop.
Save yxhuvud/f9fc14095b07ce33f2650a592757d307 to your computer and use it in GitHub Desktop.
class Foo
def foo=(other)
p other
end
def foo
p :what
end
end
f = Foo.new
f.foo ||= 43
=> :what
@yxhuvud
Copy link
Author

yxhuvud commented Jul 1, 2018

class Foo
  def foo=(other)
    p other
  end

  def foo
    p :what
    nil
  end
end

f = Foo.new

f.foo ||= 43

=> 
:what
43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment