-
Notifications
You must be signed in to change notification settings - Fork 114
Open
Description
Ruby3.1.4で実行して試したところ各選択肢の実行結果が違っていました。
prep-test/gold_answers_ja.md at dccfa77b6d3e409b7d818f4396fecf194f4b5839 · ruby-association/prep-test
解説の修正(もしくは問題の修正?)をお願いしたく存じます。
コード
class Speaker
@message = "Hello!"
class << self
@message = "Howdy!"
def speak
@message
end
end
end
__(1)__
# [実行結果]
# Hello!選択肢
A: puts Speaker.speak
B: puts Speaker.singleton_class.speak
C: puts Speaker.instance_variable_get(:@message)
D: puts Speaker.singleton_class.instance_variable_get(:@message)
解答
A: Hello!
B: Howdy!
C: Hello!
D: nil
実際の実行結果
A: Hello!
B: <main>': undefined method speak' for #Class:Speaker (NoMethodError)
C: Hello!
D: Howdy!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels