It's a bit hard to search for it. This might actually be a Rails method.
Asked
Active
Viewed 135 times
0
-
3http://stackoverflow.com/questions/1011282/ruby-whats-the-meaning-of-keyword-in – stacker Jul 28 '10 at 20:29
-
2I know `in` is a keyword, used in loops, is it a method too? If so, can you give us an example of usage? – FrustratedWithFormsDesigner Jul 28 '10 at 20:30
-
Sorry for the close vote, didn't read the comment and didn't know about `Date#in` – Marc-André Lafortune Jul 28 '10 at 20:43
-
@Marc-André no worries. not sure if this one should stay open but I guess the since alias could be good to know – Tony Jul 28 '10 at 20:48
-
1Please provide more context to this "in" – Ryan Bigg Jul 28 '10 at 22:45
2 Answers
3
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.

Chuck
- 234,037
- 30
- 302
- 389
-
Weird. I don't get that at all. "ri in" just lists a ton of methods. "ri Date.since" gives "Nothing known about Date.since" – Tony Jul 28 '10 at 20:46
-
Wrong, he means the `in` in `for project in @projects`, which is in Ruby. – Ryan Bigg Jul 28 '10 at 22:45
0
"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

nicholasklick
- 1,212
- 10
- 14
-
-
1-1. This answer is about the `in` keyword. The OP asked about the `in` method. Keywords and methods are two completely different things and have absolutely nothing to do with each other. – Jörg W Mittag Jul 28 '10 at 21:18