What will this Ruby code return? answer = "runthisnafleogw" p answer[0..2] p answer[3..6] p answer[5..5]+answer[7..7] p answer[8..8] p answer[9..9]+answer[5..5]+answer[10..11] p answer[3..3]+answer[12..12] p answer[13..13]+answer[11..11]+answer[3..3] p answer[3..4]+answer[11..11] p "answer" -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sat, Jun 5, 2010 at 2:27 AM, Srinivas Golyalla <golyalla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> What will this Ruby code return? > > answer = "runthisnafleogw" > p answer[0..2] > p answer[3..6] > p answer[5..5]+answer[7..7] > p answer[8..8] > p answer[9..9]+answer[5..5]+answer[10..11] > p answer[3..3]+answer[12..12] > p answer[13..13]+answer[11..11]+answer[3..3] > p answer[3..4]+answer[11..11] > p "answer" > >Srinivas, it will return the result of the last statement executed. In this case, it will return the string "answer". Things like this is easily verified within IRB console. Good luck, -Conrad --> You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi -- On Sat, 5 Jun 2010, Conrad Taylor wrote:> On Sat, Jun 5, 2010 at 2:27 AM, Srinivas Golyalla <golyalla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > What will this Ruby code return? > > answer = "runthisnafleogw" > p answer[0..2] > p answer[3..6] > p answer[5..5]+answer[7..7] > p answer[8..8] > p answer[9..9]+answer[5..5]+answer[10..11] > p answer[3..3]+answer[12..12] > p answer[13..13]+answer[11..11]+answer[3..3] > p answer[3..4]+answer[11..11] > p "answer" > > > Srinivas, it will return the result of the last statement executed. > In this case, it will return the string "answer".That''s true in Ruby 1.9, but in < 1.9 it will return something else.... David -- David A. Black, Senior Developer, Cyrus Innovation Inc. THE Ruby training with Black/Brown/McAnally COMPLEAT Coming to Chicago area, June 18-19, 2010! RUBYIST http://www.compleatrubyist.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thank You Conrad., In Ruby there is a command called ‘require’. Explain what this command means and write an example of how it is used to include a Ruby Gem in a file. can you guide me in getting the answer. On Jun 5, 5:41 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sat, Jun 5, 2010 at 2:27 AM, Srinivas Golyalla <golya...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > What will this Ruby code return? > > > answer = "runthisnafleogw" > > p answer[0..2] > > p answer[3..6] > > p answer[5..5]+answer[7..7] > > p answer[8..8] > > p answer[9..9]+answer[5..5]+answer[10..11] > > p answer[3..3]+answer[12..12] > > p answer[13..13]+answer[11..11]+answer[3..3] > > p answer[3..4]+answer[11..11] > > p "answer" > > Srinivas, it will return the result of the last statement executed. In this > case, it will > return the string "answer". Things like this is easily verified within IRB > console. > > Good luck, > > -Conrad > > -- > > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Dude, you really need to stop asking the rails community to do your homework. On Jun 5, 6:12 am, Srinivas Golyalla <golya...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thank You Conrad., > > In Ruby there is a command called ‘require’. Explain what this command > means and write an example of how it is used to include a Ruby Gem in > a file. > > can you guide me in getting the answer. > > On Jun 5, 5:41 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Sat, Jun 5, 2010 at 2:27 AM, Srinivas Golyalla <golya...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > > > What will this Ruby code return? > > > > answer = "runthisnafleogw" > > > p answer[0..2] > > > p answer[3..6] > > > p answer[5..5]+answer[7..7] > > > p answer[8..8] > > > p answer[9..9]+answer[5..5]+answer[10..11] > > > p answer[3..3]+answer[12..12] > > > p answer[13..13]+answer[11..11]+answer[3..3] > > > p answer[3..4]+answer[11..11] > > > p "answer" > > > Srinivas, it will return the result of the last statement executed. In this > > case, it will > > return the string "answer". Things like this is easily verified within IRB > > console. > > > Good luck, > > > -Conrad > > > -- > > > > You received this message because you are subscribed to the Google Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscrib e@googlegroups.com> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.