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


Groups > comp.lang.ruby > #3576

Help me understand this SIMPLE Ruby code, using puts in a def

From Fily Salas <fs_tigre@hotmail.com>
Newsgroups comp.lang.ruby
Subject Help me understand this SIMPLE Ruby code, using puts in a def
Date 2011-04-27 15:25 -0500
Organization Service de news de lacave.net
Message-ID <bde5d72cb289acdd7b880c6c83869049@ruby-forum.com> (permalink)

Show all headers | View raw


Hi,

I was practicing ruby and accidentally came across something that got me
thinking (nothing important but I want to know why).

Why does the example-1 works and not example-2, if all I'm doing is
moving the puts?

Example-1:
def message
  "this is working"
end
puts message.upcase


Example-2:
def message
  puts "this is working"
end
message.upcase

Can someone explain this a little bit? I could just ignore it but I
would like to know the reason.

Thanks

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

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


Thread

Help me understand this SIMPLE Ruby code, using puts in a def Fily Salas <fs_tigre@hotmail.com> - 2011-04-27 15:25 -0500
  Re: Help me understand this SIMPLE Ruby code, using puts in a def Sam Duncan <sduncan@wetafx.co.nz> - 2011-04-27 15:35 -0500
  Re: Help me understand this SIMPLE Ruby code, using puts in a def Roger Braun <roger@rogerbraun.net> - 2011-04-27 15:41 -0500
  Re: Help me understand this SIMPLE Ruby code, using puts in a def Cee Joe <cyril_jose@ymail.com> - 2011-04-27 15:47 -0500
  Re: Help me understand this SIMPLE Ruby code, using puts in a def Fily Salas <fs_tigre@hotmail.com> - 2011-04-27 18:38 -0500

csiph-web