CODE - I class Fixnum alias other_s to_s def to_s a = self + 5 return a.other_s end end #=> nil puts 5 10 #=> nil CODE - II class Fixnum alias other_s to_s def to_s self + 5 #return a.other_s end end puts 5 #<Fixnum:0x00000b> #=> nil What I know that block returns automatically its last expression. Why does `10` not the returned here, rather `#<Fixnum:0x00000b>`? But with the `return a.other_s` `10` printed - what is the concpetual difference between CODE-I and CODE - II? Please help me to understand. Thanks
on 2013-02-27 14:36
on 2013-02-27 15:04
Again, as you have been asked previously, WHY are you screwing around attempting to rewrite core classes of Ruby when you DO NOT understand how to use them properly in the first place? Drop your Eloquent Ruby book, and WORK THROUGH codecademy.com/tracks/ruby COMPLETELY! THEN post to the list if you still have problems. You have VERY sketchy Ruby knowledge which that URL will flesh out so that you understand at least the basics. DO NOT post to the list every little question you have while working through that set of tracks. Post AFTER you have COMPLETED the ENTIRE Ruby track there! I can almost guarantee you that 99.999% if your current questions will be answered once you COMPLETE the ENTIRE Ruby track there.
on 2013-02-27 15:07
On Wed, Feb 27, 2013 at 2:36 PM, Love U Ruby <lists@ruby-forum.com> wrote: > puts 5 > end > But with the `return a.other_s` `10` printed - what is the concpetual > difference between CODE-I and CODE - II? Come on, that's really simple: You do not invoke #other_s. robert
on 2013-02-27 16:09
But why mean to say when the below code works: class Simple def foo 2 + 2 end end #=> nil simple = Simple.new #=> #<Simple:0x11eb390> simple.foo #=> 4 Why not the below: class Fixnum def to_s self + 5 end end #=> nil puts 10 #<Fixnum:0x000015> #=> nil Hope my confusion is clear.
on 2013-02-27 16:32
I seriously believe now that you are trolling this list. I, for one, am done. You have been pointed over and over to documentation, to tutorials, to online FREE courses to teach you Ruby, both basic and intermediate levels. You take NO advantage of them. I will block all email from you, from the mailing list that contains your email address and username. I'd rather spend my time helping someone who really wants to learn, not half ass their learning. I hope one day you actually learn Ruby. Right now, you're not even close.
on 2013-02-27 17:56
D. Deryl Downey wrote in post #1099370: > I seriously believe now that you are trolling this list. I, for one, am > done. You have been pointed over and over to documentation, to > tutorials, > to online FREE courses to teach you Ruby, both basic and intermediate > levels. You take NO advantage of them. > Sorry! my last post was actually thrown before your one. But don't know how it appeared last. And I have seen your excellent suggestion late,when my one actually sent. Yes,I will do now, what you suggested. Thanks for the suggestions. But doing some try to understand how that url works, how to start. Yes, I want to learn not to troll. believe me. Please don't take me wrongly. Thanks
on 2013-02-28 08:52
On Wed, Feb 27, 2013 at 4:12 PM, Love U Ruby <lists@ruby-forum.com> wrote: > But why mean to say when the below code works: > Hope my confusion is clear. Yes, perfectly. It was clear all the way. But you refuse to ignore the hints you are given. By offloading thinking to other people you will never _learn_ something let alone become a programmer or software engineer. Good luck! robert
on 2013-02-28 08:57
Robert Klemme wrote in post #1099496: > On Wed, Feb 27, 2013 at 4:12 PM, Love U Ruby <lists@ruby-forum.com> > wrote: >> But why mean to say when the below code works: > >> Hope my confusion is clear. > > Yes, perfectly. It was clear all the way. But you refuse to ignore > the hints you are given. By offloading thinking to other people you > will never _learn_ something let alone become a programmer or software > engineer. > > Good luck! > > robert Thanks @Robert!
on 2013-02-28 08:59
On Wed, Feb 27, 2013 at 5:56 PM, Love U Ruby <lists@ruby-forum.com> wrote: > Yes, I want to learn not to troll. believe me. > > Please don't take me wrongly. Then take feedback serious and behave according to your stated intentions. If you don't the way you are viewed in the community won't change because people tend to judge other people by their behavior and not only by their stated intentions. robert
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.