我试图写一个简单的用户名/密码提示。我仍然是 Ruby 的初学者。
combo = Hash.new
combo["placidlake234"] = "tastychicken"
combo["xxxdarkmasterxxx"] = "pieisgood"
combo["dvpshared"] = "ilikepie"
puts "Enter your username."
username = gets.chomp
def user_check
if username = ["placidlake234"||"xxxdarkmasterxxx"||"dvpshared"]
puts "What is your password?"
password = gets.chomp
pass_check
else
puts "Your username is incorrect."
end
end
def pass_check
if password => username
puts "You have signed into #{username}'s account."
end
end
user_check()
当我尝试运行它时,我在 username in 之前收到一个奇怪的错误=> username
。