Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3041

Re: Understanding the return method

From jake kaiden <jakekaiden@yahoo.com>
Newsgroups comp.lang.ruby
Subject Re: Understanding the return method
Date 2011-04-16 18:35 -0500
Organization Service de news de lacave.net
Message-ID <76b9507cbd1e9b454860e51c06f9affe@ruby-forum.com> (permalink)
References <4aa6da7c8d4c99589c8a48a80c677218@ruby-forum.com>

Show all headers | View raw


hi fily -

  while i was answering your post, vincent answered it much better than 
i ever could have.

  the one thing that i would point out, is that it is important to 
remember that by default ruby returns the LAST statement evaluated (this 
can bite you in the arse if you forget!)

 the example you gave could also be written like this (without 
'return'):

def multiply(val1, val2 )
  val1 * val2
end

value = multiply( 10, 20 )
puts value

#=>200

 -j

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Understanding the return method Fily Salas <fs_tigre@hotmail.com> - 2011-04-16 17:41 -0500
  Re: Understanding the return method Iñaki Baz Castillo <ibc@aliax.net> - 2011-04-16 18:00 -0500
  Re: Understanding the return method Vincent Manis <vmanis@telus.net> - 2011-04-16 18:25 -0500
  Re: Understanding the return method jake kaiden <jakekaiden@yahoo.com> - 2011-04-16 18:28 -0500
  Re: Understanding the return method jake kaiden <jakekaiden@yahoo.com> - 2011-04-16 18:35 -0500
    Re: Understanding the return method 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-16 22:10 -0500
      Re: Understanding the return method Vincent Manis <vmanis@telus.net> - 2011-04-17 00:09 -0500
      Re: Understanding the return method Iñaki Baz Castillo <ibc@aliax.net> - 2011-04-17 09:41 -0500
  Re: Understanding the return method Fily Salas <fs_tigre@hotmail.com> - 2011-04-16 21:05 -0500
  Re: Understanding the return method Fily Salas <fs_tigre@hotmail.com> - 2011-04-17 07:19 -0500

csiph-web