< :the previous in number
^ :the list in numerical order
> :the next in number
P :the previous artilce (have the same parent)
N :the next (in thread)
|<:the top of this thread
>|:the next thread
^ :the parent (reply-to)
_:the child (an article replying to this)
>:the elder article having the same parent
<:the youger article having the same parent
---:split window and show thread lists
| :split window (vertically) and show thread lists
~ :close the thread frame
.:the index
..:the index of indices
"itsme213" <itsme213 / hotmail.com> schrieb im Newsbeitrag
news:I7Jrd.100267$jq5.22882 / fe2.texas.rr.com...
> def foo
> bar [:a, :b, :c]
> a
> b
> c
> end
>
> I would like a, b, and c to be local variables with values 1, 2, 3
> (positions of :a, :b, :c). Is there some implementation of
> def bar (symbol_list)
> symbol_list.each_with_index { |s, i|
> ???
> }
> end
> that will do this?
As Mark pointed out, you can't get this to work because of the compile
time decisions Ruby takes. You can either do this
def bar(*a) 0...a.size end
def foo
a,b,c = *bar(:a,:b,:c)
puts a,b,c
end
or this
def bar2(b,*a)
a.each_with_index {|s,i| eval("#{s}=#{i}",b)}
end
def foo2
bind = binding
bar2(bind, :a,:b,:c)
[:a,:b,:c].each do |sym|
puts eval(sym.to_s, bind)
end
end
which is really clumsy.
Kind regards
robert