Michael Fellinger wrote:
> some people use _ as a temporary meaningless variable, just a
> throw-away so to say.
> In this case something like
>
> hash = {:a => :b, :c => :d}
>
> and you are not interested in the :b and :d
>
> hash.each do |key, _|
> p key
> end
>
> I'm not necessarily a friend of this technique, but it seems easy on
> the minds of some people.
Right, this is exactly what I guessed it was doing (it is the same in
SML/OCaml/F#) but what value was being thrown away in the Ruby program and
where did it come from?
(1..n).inject(x) { |acc, _| yield(acc) }
--
Dr Jon D Harrop, Flying Frog Consultancy
The F#.NET Journal
http://www.ffconsultancy.com/products/fsharp_journal/?usenet