/home/arhich/rubytut/lesson12/game.rb:22:in `ask_next_letter': undefined method `call' for "ы\n":String (NoMethodError) Did you mean? caller from viselitsa2.rb:8:in `<main>' 

22 line

 letter = STDIN.gets.encode.("UTF-8").chomp 

8 line

 game.ask_next_letter 
  • MB you give the code that causes this error? - br3t

1 answer 1

The error message says what's wrong.

 letter = STDIN.gets.encode.("UTF-8").chomp # ^ 

... the same as:

 letter = STDIN.gets.encode.call("UTF-8").chomp # ^^^^^ 

encode was called without arguments. This form really exists and converts to Encoding.default_internal ; returns, naturally, a string.
If you wanted to transmit ("UTF-8") in encode , then you have an extra point there.

Such syntax exists so that Proc objects are not too cumbersome to call, as compared to normal method calls. But you got it by chance.