こんにちは、私はそれが書かれたようにしましたが、エクササイズ18ではエラーです。私はこのエラーを理解しないRubyエクササイズ18未定義のメソッドですが、私はメソッドを定義しました
exercise18_names_variables_code_functions.rb:25:in `<class:Exercise18_NamesVariablesCodeFunctions>': undefined method `print_two' for Exercise18_NamesVariablesCodeFunctions:Class (NoMethodError)
Did you mean? print
from exercise18_names_variables_code_functions.rb:1:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
:
class Exercise18_NamesVariablesCodeFunctions
# this one is like your scripts with ARGV
def print_two(*args)
arg1, arg2 = args
puts "arg1: #{arg1}, arg2: #{arg2}"
end
# ok, that *args is actually pointless, we can just do this
def print_two_again(arg1, arg2)
puts "arg1: #{arg1}, arg2: #{arg2}"
end
# this just takes one argument
def print_one(arg1)
puts "arg1: #{arg1}"
end
# this one takes no arguments
def print_none()
puts "I got nothin'."
end
print_two("Zed","Shaw")
print_two_again("Zed","Shaw")
print_one("First!")
print_none()
end
は、ここに私のエラーです。私はすべての方法を定義しました。私は自分を追加するとき。すべてのメソッドに作用します。
ありがとうございました。今分かります。 – AlaskaStack