そのうち、 サポートページ とかに正式なの出来るのかもしれませんけど、2013/8/31時点では見当たら無かったので。
===== ===== Page こうじゃないかなーと思った部分 ===== ===== 136 is_a? -> instance_of?
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時点では見当たら無かったので。
===== ===== Page こうじゃないかなーと思った部分 ===== ===== 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 |
# https://twitter.com/yuroyoro/status/365050923237638144 | |
class Array | |
def ^(other) | |
(self | other) - (self & other) | |
end | |
end | |
[1, 2, 3] ^ [3, 4] #=> [1, 2, 4] |
# https://github.com/rubinius/rubinius/blob/7866fbd80db7fe6e1de2627f5442c8abe6ce51ad/kernel/common/enumerable.rb#L113 | |
# https://github.com/rubinius/rubinius/blob/7866fbd80db7fe6e1de2627f5442c8abe6ce51ad/kernel/common/enumerable.rb#L428 | |
class Foo | |
def each | |
yield false | |
yield nil | |
end | |
end |