This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/shouichi/a077b5b903997e16785a - ruby-core [66257] | |
## ruby 2.2.0preview1 on Ubuntu | |
Occurs 4time/10times | |
$ gem install bundler | |
$ bundle install | |
$ bundle exec rspec spec.rb | |
F/home/igarashi/.rbenv/versions/2.2.0-preview1/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:486: [BUG] vm_call_cfunc - cfp consistency error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = [1,2,3] | |
sum = 0 | |
for i in array | |
sum += i | |
end | |
puts sum #=> 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = [1,2,3] | |
sum = 0 | |
array.each do |i| | |
sum += i | |
end | |
puts sum #=> 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = [1,2,3] | |
result = array.inject(0) do |sum, i| | |
sum + i | |
end | |
puts result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = [1,2,3] | |
puts array.inject(:+) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support' | |
require 'active_support/core_ext' | |
array = [1,2,3] | |
puts array.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ModifyReverse | |
def reverse | |
"*" + super + "*" | |
end | |
end | |
puts "abcde".reverse #=> edcba | |
class String | |
prepend ModifyReverse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def method_missing(name, *args) | |
puts name, args | |
end | |
end | |
Foo.new.bar("abc") #=> bar abc |