From: Michael Fellinger Date: 2007-05-29T16:17:17+09:00 Subject: Re: Underscore 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. ^ manveru On 5/29/07, Jon Harrop wrote: > Logan Capaldo wrote: > >> > However, I'd probably write it like: > >> > def nest(x, n = 2) > >> > (1..n).inject(x) { |acc, _| yield(acc) } > >> > end > >> > >> I don't understand this one. I think "inject" is a fold and "yield" > >> returns a value and a continuation. Looks like the continuation is > >> ignored the next time it is accumulated, but won't the result have a > >> continuation in it? > > inject is a fold. yield is not a continuation, but rather a way of > > accessing the passed in function (block) anonymously. > > > > def f > > yield > > end > > > > def f1(&b) > > b.call > > end > > > > f { puts "Does the same thing" } > > f1 { puts "Does the same thing" } > > I see. So that was equivalent to: > > let rec nest ?(n=2) x f = > Seq.fold (fun acc -> f acc) x {1 .. n} > > but what is the meaning of the "_" in the Ruby "|acc, _|"? > > -- > Dr Jon D Harrop, Flying Frog Consultancy > The F#.NET Journal > http://www.ffconsultancy.com/products/fsharp_journal/?usenet > >