开发者

What does the ruby method "in" do?

It's a bit hard to search for it. This might ac开发者_Go百科tually be a Rails method.


If you want to know what any method does, just do "ri the_method" from the shell. In this case, "ri in" reveals Date#in. "ri Date.in" gives:

Alias for #since

In turn, "ri Date.since" gives:

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

And yes, it's in ActiveSupport.


"in" is used as an alternative to the array.each do |a| syntax

array = [1,2,3,4]

for a in array
 puts a
end

1
2
3
4
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜