dimanche 27 décembre 2020

Does anyone know why IRB gives the syntax error in block?

It's just plain ruby. Any ideas why the code below throws syntax error?

irb(main):001:0> def count_valid_policies(input)
irb(main):002:1>   counter = 0
irb(main):003:1>   policies = input.split("\n")
irb(main):004:1>   policies.each do |policy|
irb(main):005:2*     valid?(policy) && counter++
irb(main):006:2*   end
irb(main):007:1>
irb(main):008:1>   puts counter
irb(main):009:1> end
Traceback (most recent call last):
        1: from /usr/local/bin/irb:11:in `<main>'
SyntaxError ((irb):6: syntax error, unexpected keyword_end)
  end
  ^~~
(irb):9: syntax error, unexpected end-of-input, expecting keyword_end

Aucun commentaire:

Enregistrer un commentaire