Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
class Example
|
||||
def foo
|
||||
42
|
||||
end
|
||||
def bar(arg1, arg2, &block)
|
||||
block.call arg1, arg2
|
||||
end
|
||||
end
|
||||
|
||||
symbol = :foo
|
||||
Example.new.send symbol # => 42
|
||||
Example.new.send( :bar, 1, 2 ) { |x,y| x+y } # => 3
|
||||
args = [1, 2]
|
||||
Example.new.send( "bar", *args ) { |x,y| x+y } # => 3
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
class Example
|
||||
private
|
||||
def privacy; "secret"; end
|
||||
public
|
||||
def publicity; "hi"; end
|
||||
end
|
||||
|
||||
e = Example.new
|
||||
e.public_send :publicity # => "hi"
|
||||
e.public_send :privacy # raises NoMethodError
|
||||
e.send :privacy # => "secret"
|
||||
Loading…
Add table
Add a link
Reference in a new issue