ボクシング・デーのRuby #とは
$ cat box.rb
class String
def greet
"Hello, #{self}!"
end
end
box = Ruby::Box.new
box.eval <<'END'
class String
def greet
"Happy holidays, #{self}!"
end
end
END
puts "World".greet
box.eval <<'END'
puts "World".greet
END
$ RUBY_BOX=1 ruby box.rb
ruby: warning: Ruby::Box is experimental, and the behavior may change in the future!
See https://docs.ruby-lang.org/en/4.0/Ruby/Box.html for known issues, etc.
Hello, World!
Happy holidays, World!
もっとおもしろいことできそうよね
Ruby::Box ダイジェスト紹介(Ruby 4.0.0 新機能) - STORES Product Blog
https://product.st.inc/entry/2025/12/25/134453