0
定义名为first_longer_than_second
的方法,其参数为first
,另一个称为second
。如果传入的first
字大于或等于second
字的长度,则该方法将返回true
。否则返回false。以下是如何将被调用的方法和预期收益:将两个字符串的长度与Ruby进行比较
这是我有:
def first_longer_than_second(first, second)
if first.length >= second.length
puts true
else
puts false
end
end
我得到错误,我不知道为什么。
请问你能发表什么错误? – bork
请正确格式化您的代码 - https://meta.stackexchange.com/questions/18614/style-guide-for-questions-and-answers – skwidbreth
在黑暗中拍摄时不知道您的错误是什么,但'puts'会打印然后返回'nil',这不像你的方法应该做的那样。 – jmschles