我需要在 Ruby 中缩进我的代码吗?

编程入门 行业动态 更新时间:2024-10-26 14:35:00
本文介绍了我需要在 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 中缩进我的代码吗?

本文发布于:2023-11-27 08:47:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637352.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   Ruby

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!