Home  >  Q&A  >  body text

ruby中出现unexpected tIDENTIFIER!求大神指点

def test(name)
  yield(name)
end

test("licheng"){|name| puts "hello #{name}"}

上面这段代码出现以下错误,不知为何?

-e:1:in `load': /Users/lic/RubymineProjects/test/test1.rb:1: syntax error, unexpected tIDENTIFIER, expecting end-of-input (SyntaxError)
test("licheng"){|name| puts "hell...
...                               ^
    from -e:1:in `<main>'
阿神阿神2712 days ago661

reply all(1)I'll reply

  • 黄舟

    黄舟2017-04-22 09:02:09

    I found the problem. When I used rubymine on mac, it might have jumped to windows mode. There was an "n" at the end of each sentence

    reply
    0
  • Cancelreply