[英]how to increase count by 1 in ruby?
I am using the below code to get the number of records. 我正在使用下面的代码来获取记录数。
self.size.to_s
How can i add '1' to the size from above? 如何从上方将“ 1”添加到尺寸?
self.size.next.to_s
(self.size + 1).to_s
#像这样
You can either add it before converting to string 您可以先添加它,然后再转换为字符串
(self.size + 1).to_s
Or if you already have a string 或者如果您已经有一个字符串
"2".to_i + 1
Combined this could be something like 结合起来这可能像
self.size.to_s.to_i + 1
but that is hardly practical 但这几乎不可行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.