Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

問題と解答の選択数不一致(Gold, Q26) #22

Open
t-ueno-ruby opened this issue Aug 29, 2024 · 0 comments
Open

問題と解答の選択数不一致(Gold, Q26) #22

t-ueno-ruby opened this issue Aug 29, 2024 · 0 comments

Comments

@t-ueno-ruby
Copy link

t-ueno-ruby commented Aug 29, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant