Created
May 21, 2025 14:49
-
-
Save yancya/bc9aace385c90b586ebec8079dfe0f3b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 A | |
def initialize | |
@tmp = 1 | |
end | |
def to_s | |
"#{@tmp}" | |
end | |
end | |
class B | |
def to_s | |
A.new.to_s | |
end | |
end | |
puts B.new.to_s #=> 1 |
Author
yancya
commented
May 21, 2025
$ ruby -v
ruby 3.4.4 (2025-05-14 revision a38531fd3f) +PRISM [arm64-darwin24]
$ ruby hoge.rb
1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment