Sha256: 715feb8b9e4af065150860b24b75e6168adfb2907a0c50f0262b1518abb0f010
Contents?: true
Size: 990 Bytes
Versions: 4
Compression:
Stored size: 990 Bytes
Contents
class A def a_method(a,b) p a, b end end class B < A def a_method(b, a) p "in B" super end def c_method(b) end end class C def method_missing(id, *args, &block) p "mm: #{id}, #{args}" end end class TestSend def self.main puts "send" p A.new.send("a_method", 1, 2) p B.new.send("a_method", 1, 2) puts "respond_to?" p A.new.respond_to?(:a_method) p A.new.respond_to?(:to_s) p A.new.respond_to?(:inspect) p A.new.respond_to?(:b_method) p A.new.respond_to?(:c_method) puts "method_missing" p C.new.respond_to?(:blah_blah) C.new.blah_blah(1,2,3) begin A.new.blah_blah puts "FAILURE?" rescue NoMethodError puts "catched!!!" end begin A.not_a_method rescue NoMethodError p "goood" end puts "class Method" m = "hallo".method(:to_s) p m p m.call a = [1,2,3] m = a.method(:+) p m p m.call([2,3]) p m p a end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
superchris-rubyjs-0.8.2 | test/test_send.rb |
rubyjs-0.7.0 | test/test_send.rb |
rubyjs-0.8.0 | test/test_send.rb |
rubyjs-0.7.1 | test/test_send.rb |