ruby: What's the meaning of keyword "in"

ruby

Solution

You should be able to do the following:

for i in 0..10 do
  puts i
end

The expression `1 in (0..10)` that you mention won't work because a constant (1) can't vary over a range - it's a constant! You need to name a variable before the `in` keyword.

Hope that helps.

See this page as well.

Problem

When I find the keyword "in" in ruby first time. I think maybe I can do that: 1 in (0..10) But it look like I cannot use it like that way. Then I search it in ruby-lang.org, and google it. There is no answer! What's the meaning of keyword "in" in ruby?

Original source

Related problems