有没有快速的方法来找到Ruby中的缺少的结尾?

前端之家收集整理的这篇文章主要介绍了有没有快速的方法来找到Ruby中的缺少的结尾?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Syntax error,unexpected $end,expecting keyword_end

我们都去过了!假设足够的代码改变了,快速浏览git diff或类似的内容并不明显,是否有一种简单的方法来找到缺少的结尾(缺少切换到基于缩进的语言,如Python)?

FWIW,我使用Sublime Text 2作为我的编辑器.

@H_403_10@

@R_403_323@

如果您使用的是Ruby 1.9,请在运行ruby程序时尝试使用-w标志.
# t.rb
class Example
  def meth1
    if Time.now.hours > 12
      puts "Afternoon"
  end
  def meth2
    # ...
  end
end

ruby t.rb  
=> t.rb:10: Syntax error,expecting keyword_end

ruby -w t.rb
=> t.rb:5: warning: mismatched indentations at 'end' with 'if' at 3
   t.rb:9: warning: mismatched indentations at 'end' with 'def' at 2
   t.rb:10: Syntax error,expecting keyword_end

资源:

http://pragdave.blogs.pragprog.com/pragdave/2008/12/ruby-19-can-check-your-indentation.html

@H_403_10@ @H_403_10@ 原文链接:https://www.f2er.com/ruby/273690.html

猜你在找的Ruby相关文章