[英]What does the ruby method “in” do?
It's a bit hard to search for it. 搜索起来有点困难。 This might actually be a Rails method.
这实际上可能是Rails方法。
If you want to know what any method does, just do "ri the_method" from the shell. 如果您想知道任何方法的作用,那么只需在shell中执行“ ri the_method”即可。 In this case, "ri in" reveals
Date#in
. 在这种情况下,“ ri in”显示
Date#in
。 "ri Date.in" gives: “ ri Date.in”给出:
Alias for #since
#asnce的别名
In turn, "ri Date.since" gives: 反过来,“ ri Date.since”给出:
Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) and then adds the specified number of seconds
将日期部分设置为一天的开始(0:00),将日期转换为时间(或日期时间,如有必要),然后添加指定的秒数
And yes, it's in ActiveSupport. 是的,它在ActiveSupport中。
"in" is used as an alternative to the array.each do |a| “ in”用作数组的替代。每个| a | a |。 syntax
句法
array = [1,2,3,4]
for a in array
puts a
end
1
2
3
4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.