tag:blogger.com,1999:blog-4545081472093386800.post3471693034302512996..comments2023-05-09T05:34:51.555-04:00Comments on the Garden of Forking Paths: Metaprogramming in RubyZach VanderVeenhttp://www.blogger.com/profile/02442507412891534071noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-4545081472093386800.post-52522478758249376262011-08-24T21:22:51.713-04:002011-08-24T21:22:51.713-04:00That's funny, I actually ask that as an interv...That's funny, I actually ask that as an interview question! I meant to say overriding, not overloading. Overriding is redefining a base class method in an inherited class. Overloading is, as you say, providing different parameterizations of the same method.Zach VanderVeenhttps://www.blogger.com/profile/02442507412891534071noreply@blogger.comtag:blogger.com,1999:blog-4545081472093386800.post-41370792400084212512011-08-24T20:28:43.114-04:002011-08-24T20:28:43.114-04:00You mention overloading a class, and before you me...You mention overloading a class, and before you mentioned overloading the default class, but one of the articles you linked also mentioned that you can't do the sort of overloading that is typical in Java.<br /><br />As I understand it the Java overloading is defining the same method multiple times, but with different inputs. So you might have TestFunction(int a, int b) and also TestFunction(str c) and it will know which one you mean based on what you pass in.<br /><br />But your use of it seems to imply overwriting the base functionality. Are there more precise terms for those situations, or is it just the difference between overloading classes and overloading methods?Mecherathhttps://www.blogger.com/profile/12133247922632052529noreply@blogger.comtag:blogger.com,1999:blog-4545081472093386800.post-42949720751619246022011-08-23T22:49:54.222-04:002011-08-23T22:49:54.222-04:00Yes, it's an interesting way of programming. ...Yes, it's an interesting way of programming. You can't do any type-checking at compilation (since there is no compilation), but you have a lot of flexibility at run-time. You can overload any class--including base type classes like true and false--so you can do some really wild stuff!<br /><br />What I like most about Ruby, though, is how nice the syntax is. It really is easy to get going and write very readable code.Zach VanderVeenhttps://www.blogger.com/profile/02442507412891534071noreply@blogger.comtag:blogger.com,1999:blog-4545081472093386800.post-50829066070666666952011-08-23T21:56:39.257-04:002011-08-23T21:56:39.257-04:00I wandered around some of the Ruby links you poste...I wandered around some of the Ruby links you posted for a while, and saw that since it uses dynamic typing, an object that inherits methods from multiple classes doesn't have to be re-cast to make use of them all. Apparently that's called Duck-typing, based on this quote:<br /><br />"If it quacks like a duck and it walks like a duck then it must be of type Duck."Mecherathhttps://www.blogger.com/profile/12133247922632052529noreply@blogger.com