Skip to content

Instantly share code, notes, and snippets.

@RyanScottLewis
Created June 14, 2010 14:52
Show Gist options
  • Save RyanScottLewis/437785 to your computer and use it in GitHub Desktop.
Save RyanScottLewis/437785 to your computer and use it in GitHub Desktop.
class Foo
def subject(&blk)
if block_given?
blk.call(@subject) # How do I pass by reference and not by value here?
else
@subject
end
end
end
f = Foo.new
p f.subject #=> nil
f.subject do |s|
p s.object_id
s = ['one', 'two', 'three']
s.pop
p s #=> ['one', 'two']
end
p f.subject #=> nil... want it to be ['one, 'two']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment