Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby BUS error
N = 500
class X
N.times do |i|
define_method("m#{i}") do
(1..10000).to_a.map { rand }
end
end
define_method("m#{N}") do
puts "END"
end
end
def prepend(lmd, i)
lambda { |x|
puts "m#{i}"
x.send("m#{i}")
lmd.call(x)
}
end
def test
last = lambda { |x|
puts "END"
}
(N-1).downto(0) do |i|
last = prepend(last, i)
end
x = X.new
last.call(x)
end
test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.