<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-20975090.post1265651246921410904..comments</id><updated>2007-08-20T13:21:07.394-05:00</updated><title type='text'>Comments on Headius: Creating a Field-Initializing 'new' Method</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.headius.com/feeds/1265651246921410904/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default'/><link rel='alternate' type='text/html' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html'/><author><name>Charles Oliver Nutter</name><uri>http://www.blogger.com/profile/06400331959739924670</uri><email>headius@headius.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-20975090.post-4626035332984266181</id><published>2007-08-20T13:21:07.394-05:00</published><updated>2007-08-20T13:21:07.394-05:00</updated><title type='text'>Aman: yes, initializing the instance variables dir...</title><content type='html'>Aman: yes, initializing the instance variables directly might be a better option. And the reason I puw new! in class is because only classes can be instantiated; putting new on all Objects wouldn't be appropriate, since you can't new an arbitrary object.&lt;BR/&gt;&lt;BR/&gt;e.g.&lt;BR/&gt;&lt;BR/&gt;a = "foo"&lt;BR/&gt;a.new! # doesn't make sense</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/4626035332984266181'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/4626035332984266181'/><link rel='alternate' type='text/html' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html?showComment=1187634067394#c4626035332984266181' title=''/><author><name>Charles Oliver Nutter</name><uri>http://www.blogger.com/profile/06400331959739924670</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='10654842259138240802'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html' ref='tag:blogger.com,1999:blog-20975090.post-1265651246921410904' source='http://www.blogger.com/feeds/20975090/posts/default/1265651246921410904' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-20975090.post-1853863639223151913</id><published>2007-08-20T12:53:12.216-05:00</published><updated>2007-08-20T12:53:12.216-05:00</updated><title type='text'>Cool solution! I also learnt something new, ie, cl...</title><content type='html'>Cool solution! I also learnt something new, ie, class MyClass...end is same as  MyClass = Class.new {...}&lt;BR/&gt;&lt;BR/&gt;One suggestion though... supposing we didn't want setters for some of our attributes (to be used internally only) -- in that case we'll not have "#{key}=", however,  we may want the attribute initialized using the constructor (new!). For this, I'd use&lt;BR/&gt;new_obj.instance_eval "@#{key}=#{value}"&lt;BR/&gt;instead of&lt;BR/&gt;new_obj.send "#{key}=", value&lt;BR/&gt;&lt;BR/&gt;Do you think that's okay?&lt;BR/&gt;&lt;BR/&gt;Also, I wanted to ask something regarding the explanation about putting new! in Class. How is it different from putting it in Object?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/1853863639223151913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/1853863639223151913'/><link rel='alternate' type='text/html' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html?showComment=1187632392216#c1853863639223151913' title=''/><author><name>Aman King</name><uri>http://www.wikyblog.com/AmanKing</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html' ref='tag:blogger.com,1999:blog-20975090.post-1265651246921410904' source='http://www.blogger.com/feeds/20975090/posts/default/1265651246921410904' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-20975090.post-156910987850739270</id><published>2007-06-03T21:06:29.473-05:00</published><updated>2007-06-03T21:06:29.473-05:00</updated><title type='text'>Very clever, thank you for posting this.</title><content type='html'>Very clever, thank you for posting this.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/156910987850739270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/156910987850739270'/><link rel='alternate' type='text/html' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html?showComment=1180922789473#c156910987850739270' title=''/><author><name>Jason Seifer</name><uri>http://www.railsenvy.com</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html' ref='tag:blogger.com,1999:blog-20975090.post-1265651246921410904' source='http://www.blogger.com/feeds/20975090/posts/default/1265651246921410904' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-20975090.post-8791981161534108434</id><published>2007-06-01T23:58:19.767-05:00</published><updated>2007-06-01T23:58:19.767-05:00</updated><title type='text'>I think this solution, while cute, is too complex....</title><content type='html'>I think this solution, while cute, is too complex.&lt;BR/&gt;&lt;BR/&gt;eg:&lt;BR/&gt;&lt;BR/&gt;class Person &lt; Struct.new(:firstname, :lastname)&lt;BR/&gt;&lt;BR/&gt;You can also just extend OpenStruct if you don't know what fields you will use ahead of time.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/8791981161534108434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/8791981161534108434'/><link rel='alternate' type='text/html' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html?showComment=1180760299767#c8791981161534108434' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html' ref='tag:blogger.com,1999:blog-20975090.post-1265651246921410904' source='http://www.blogger.com/feeds/20975090/posts/default/1265651246921410904' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-20975090.post-485019092266814651</id><published>2007-06-01T13:04:39.092-05:00</published><updated>2007-06-01T13:04:39.092-05:00</updated><title type='text'>Sure, but I think this feature is really handy and...</title><content type='html'>Sure, but I think this feature is really handy and perhaps a good number of developers like to have it in their projects, how many copies/versions of the code will exist? perhaps it won't make it into mainstream Ruby but I wonder if there is an extension project (like Java's jakarta-commons) where this feature may find a home.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/485019092266814651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/485019092266814651'/><link rel='alternate' type='text/html' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html?showComment=1180721079092#c485019092266814651' title=''/><author><name>Andres Almiray</name><uri>http://jroller.com/page/aalmiray</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html' ref='tag:blogger.com,1999:blog-20975090.post-1265651246921410904' source='http://www.blogger.com/feeds/20975090/posts/default/1265651246921410904' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-20975090.post-801151699046840983</id><published>2007-06-01T09:33:52.789-05:00</published><updated>2007-06-01T09:33:52.789-05:00</updated><title type='text'>Actually, I think my point was that Ruby doesn't n...</title><content type='html'>Actually, I think my point was that Ruby doesn't need to have language-level features like this added because it's trivial to extend the language to support them. There's probably no chance of this getting into mainstream Ruby since anyone could load those 20-25 lines of code themselves and have the feature available. That's what I love about Ruby...it may not have feature X from some other language, but it's almost always trivial to add it using a tiny amount of code.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/801151699046840983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/801151699046840983'/><link rel='alternate' type='text/html' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html?showComment=1180708432789#c801151699046840983' title=''/><author><name>Charles Oliver Nutter</name><uri>http://www.blogger.com/profile/06400331959739924670</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='10654842259138240802'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html' ref='tag:blogger.com,1999:blog-20975090.post-1265651246921410904' source='http://www.blogger.com/feeds/20975090/posts/default/1265651246921410904' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-20975090.post-6524088415440832921</id><published>2007-06-01T06:45:37.740-05:00</published><updated>2007-06-01T06:45:37.740-05:00</updated><title type='text'>Hmmm nice to see Ruby taking hints from Groovy... ...</title><content type='html'>Hmmm nice to see Ruby taking hints from Groovy... ;-)&lt;BR/&gt;This is surely helpful, what are the odds of this feature making into mainstream Ruby?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/6524088415440832921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20975090/1265651246921410904/comments/default/6524088415440832921'/><link rel='alternate' type='text/html' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html?showComment=1180698337740#c6524088415440832921' title=''/><author><name>Andres Almiray</name><uri>http://jroller.com/page/aalmiray</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.headius.com/2007/06/creating-field-initializing-new-method.html' ref='tag:blogger.com,1999:blog-20975090.post-1265651246921410904' source='http://www.blogger.com/feeds/20975090/posts/default/1265651246921410904' type='text/html'/></entry></feed>