Skip to content

Instantly share code, notes, and snippets.

@bricker
Created August 7, 2012 23:31
Show Gist options
  • Save bricker/3290538 to your computer and use it in GitHub Desktop.
Save bricker/3290538 to your computer and use it in GitHub Desktop.
class Something
private
def words
"Hello"
end
end
class Else < Something
end
begin
puts "running `Else.new.words`"
words = Else.new.words
puts words
rescue Exception => e
puts e
end
begin
puts "running `Else.new.send(:words)`"
words = Else.new.send(:words)
puts words
rescue Exception => e
puts e
end
##########################
#=> running `Else.new.words`
#=> private method `words' called for #<Else:0x007f7fc984dff0>
#=> running `Else.new.send(:words)`
#=> Hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment