Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Created March 31, 2010 14:39
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 j1n3l0/350409 to your computer and use it in GitHub Desktop.
Save j1n3l0/350409 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
class Foo
attr_accessor :bar
def initialize
@bar = "bar"
yield( self ) if block_given?
return self
end
end
foo = Foo.new { |s| s.bar = "baz" }
puts foo.bar # prints baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment