-1
나는 이것을 멀리 만들었지 만, 잘못된 위치에 넣었다고 가정하기 때문에 .to_i와 .to_sym 메서드를 추가 할 위치를 모른다. 누군가 나를 도울 수 있습니까? "NilClass 정의되지 않은 메서드`to_sym = '전무는"Ruby에서 문자열을 기호와 정수로 변환하기
movies = {
spiderman: 3,
superman: 4,
batman: 5
}
puts "what movie do you like?"
choice = gets.chomp
case choice
when 'add'
puts "What movie do you want to add?"
title.to_sym = gets.chomp
puts "what is the rating of that movie?"
rating.to_i = gets.chomp
movies[title]=rating
puts "Added!"
when 'update'
puts "What movie would you like to update?"
title = gets.chomp
puts "Updated!"
when 'display'
movies.each do |movies, ratings|
puts "#{movies}: #{ratings}"
end
puts "Movies!"
when 'delete'
puts "What movie would you like to delete from the list?"
title = gets.chomp
puts "Deleted!"
else
puts "Error!"
end
확인. 그게 효과가 있었어. 이제 이해가된다. 방금 도착하자마자 chomp를 추가하는 데 익숙해졌습니다. 그래도 고마워 – user3324987