そのうち、 サポートページ_ とかに正式なの出来るのかもしれませんけど、2013/8/31時点では見当たら無かったので。
136 is_a? -> instance_of?
| $VERBOSE = true | |
| class Super | |
| def a | |
| "super_a" | |
| end | |
| def b | |
| "super_b" + c | |
| end |
| behavior :array_uniq_on_dupulicated_elements, :shared => true do | |
| it "returns a squashed array" do | |
| verify([1, 1].send(@method)).is.eq([1]) | |
| end | |
| end | |
| describe "Array#uniq" do | |
| context "when elements are duplicated" do | |
| verify.behavior(:array_uniq_on_dupulicated_elements, :uniq) |
| describe "Foo" do | |
| context "Bar" do | |
| it "Baz" do | |
| end | |
| end | |
| end | |
| #=> "Foo Bar Baz" | |
| describe "Foo" do |
| $VERBOSE = true | |
| class Super | |
| class << self | |
| CONS = :Singleton | |
| end | |
| CONS = :Super | |
| end |
そのうち、 サポートページ_ とかに正式なの出来るのかもしれませんけど、2013/8/31時点では見当たら無かったので。
136 is_a? -> instance_of?
| class Integer | |
| def pred | |
| self - 1 | |
| end | |
| end | |
| 1.pred #=> 0 | |
| 0.pred #=> -1 |
| class Array | |
| def init | |
| self[0..-2] | |
| end | |
| end | |
| [1, 3, 7].init #=> [1, 3] |
rubinius 2.0.0.n224 (1.9.3 e91782d0 2013-08-12 JI) [x86_64-unknown-linux-gnu]
Class.allocate.allocate #=> pass
Class.allocate.new #=> crash
Class.allocate.allocate.send(:initialize) #=> crash| # find_longest_api_name | |
| # 2013 Kenichi Kamiya | |
| # ruby -v: ruby 2.1.0dev (2013-08-10 trunk 42476) [x86_64-linux] | |
| $VERBOSE = true | |
| class BasicObject | |
| def longest_method_name | |
| (methods(true) | private_methods(true)).reject { |name| | |
| /\Alongest_(?:instance_)?method_name\z/ =~ name }.max_by(&:length) |
| RUBY_DESCRIPTION #=> "ruby 2.1.0dev (2013-08-09 trunk 42473) [x86_64-linux] | |
| $VERBOSE = true | |
| obj = Object.new | |
| mod = Module.new.taint | |
| obj.taint.singleton_class.tainted? #=> true | |
| obj2 = Object.new |