我需要在 Ruby 中缩进我的代码吗? [英] Do I need to indent my code in Ruby?

查看:40
本文介绍了我需要在 Ruby 中缩进我的代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你会认为这是一个简单的问题,但我在任何地方都找不到答案.>_<

You would think that this would be an easy question, but I can't find the answer anywhere. >_<

如果我的代码缩进不正确,Ruby 会抛出语法错误吗?例如,这样的代码会起作用吗?

Will Ruby throw syntax errors if my code is indented incorrectly? For example, would code like this work?

if str.blank?
  str = "Hello World"
no_input = true
  end

显然,这是不好的风格,无论如何我都应该正确缩进.我想知道我是否可以排除它作为调试会话期间错误的原因.

Obviously, this is bad style and I should indent correctly regardless. I want to know whether I can rule it out as the cause of a bug during debugging sessions.

推荐答案

是的,它会起作用.Ruby 只查找换行符.

Yes, it would work. Ruby only looks for the line breaks.

但由于代码可读性也非常重要,因此我认为您应该注意空格.

But since code readability is also very important, I'd say you should take care of whitespace if only for that sake.

这篇关于我需要在 Ruby 中缩进我的代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆