From: Brandon Weaver Date: 2012-09-22T00:35:04+09:00 Subject: Re: Proc and lambdas --047d7b339c3b95ed8704ca37fb3b Content-Type: text/plain; charset=ISO-8859-1 Suggested reading is on Blocks, Procs and Lambdas: http://bit.ly/NGQTjT Have a nice day, Brandon Weaver On Fri, Sep 21, 2012 at 7:16 AM, Jan E. wrote: > Hi, > > This is not a homework forum. Apart from that, your description is far > too vague to make anything useful out of it. Procs are just a tool, you > can use them in all kinds of ways. So saying "find the word using a > proc" is like saying "sort an array using methods". > > The usual solution to "get the smallest/biggest value" is to use the > method Enumerable#max_by (or min_by): > > http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-max_by > > words = [ > 'a', > 'abc', > 'abcde', > 'ab' > ] > puts words.max_by &:length > > -- > Posted via http://www.ruby-forum.com/. > > --047d7b339c3b95ed8704ca37fb3b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Suggested reading is on Blocks, Procs and Lambdas:=A0http://bit.ly/NGQTjT

Have a nice day,

Brandon Weaver

On F= ri, Sep 21, 2012 at 7:16 AM, Jan E. <lists@ruby-forum.com> wrote:
Hi,

This is not a homework forum. Apart from that, your description is far
too vague to make anything useful out of it. Procs are just a tool, you
can use them in all kinds of ways. So saying "find the word using a proc" is like saying "sort an array using methods".

The usual solution to "get the smallest/biggest value" is to use = the
method Enumerable#max_by (or min_by):

http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-m= ax_by

words =3D [
=A0 'a',
=A0 'abc',
=A0 'abcde',
=A0 'ab'
]
puts words.max_by &:length

--047d7b339c3b95ed8704ca37fb3b--