# Re: Simple copy of attributes

**URL:** <https://www.ruby-forum.com/t/re-simple-copy-of-attributes/79971>\
**Category:** Ruby\
**Created:** [December 20, 2006, 7:20pm UTC](https://www.ruby-forum.com/t/re-simple-copy-of-attributes/79971 "2006-12-20T19:20:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [December 20, 2006, 7:20pm UTC](https://www.ruby-forum.com/t/re-simple-copy-of-attributes/79971/1 "2006-12-20T19:20:43Z")

</div>

From: Trans [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

> Facets has Kernel#set\_from:
> 
> bidule.set\_from(biniou, :foo, :bar, :baz)

Out of curiosity, why put that in Kernel instead of Object?

Actually, what heuristic do people use in general for adding methods to  
Kernel versus putting them in Object? Assuming that my oh-so-pretty flow  
diagram[1] is correct, the end functionality should be equivalent. Is it  
just a matter of semantics as to where they ought to go?

[1] [http://phrogz.net/RubyLibs/RubyMethodLookupFlow.png](http://phrogz.net/RubyLibs/RubyMethodLookupFlow.png)

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [December 20, 2006, 7:22pm UTC](https://www.ruby-forum.com/t/re-simple-copy-of-attributes/79971/2 "2006-12-20T19:22:51Z")

</div>

Gavin K. wrote:

> just a matter of semantics as to where they ought to go?
> 
> [1] [http://phrogz.net/RubyLibs/RubyMethodLookupFlow.png](http://phrogz.net/RubyLibs/RubyMethodLookupFlow.png)

It is something even experienced ruby programmer’s can fail to realize:  
Object class has NO methods. ri is somewhat misleading in this regard,  
and the functionality equivalency you mention often means it goes  
unnoticed. it certainly surprised me when i first discovered it. While  
only matz can say exactly why, i think Object is left empty for end  
programmers to add their extension methods to --that way they are  
easily distinguished from built-in Kernel methods. Hence a lower-level  
lib like Facets uses Kernel, while a higher-level app like Basecamp  
would use Object --at least that’s my take on it.

btw that reminds me – YAML/Syck is sticking some methods in Object,  
that perhaps would be more appropriate in Kernel (?)

irb(main):002:0\> p Object.instance\_methods(false)  
[]  
=\> nil  
irb(main):003:0\> require ‘yaml’  
=\> true  
irb(main):004:0\> p Object.instance\_methods(false)  
[“taguri”, “taguri=”, “to\_yaml\_properties”, “to\_yaml”,  
“to\_yaml\_style”]

t.

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [December 20, 2006, 7:53pm UTC](https://www.ruby-forum.com/t/re-simple-copy-of-attributes/79971/3 "2006-12-20T19:53:20Z")

</div>

On 12/19/06, Trans [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Actually, what heuristic do people use in general for adding methods to  
> > only matz can say exactly why, i think Object is left empty for end  
> > =\> nil  
> > irb(main):003:0\> require ‘yaml’  
> > =\> true  
> > irb(main):004:0\> p Object.instance\_methods(false)  
> > [“taguri”, “taguri=”, “to\_yaml\_properties”, “to\_yaml”,  
> > “to\_yaml\_style”]
> 
> t.

I’m sorry for this question, but I’m a newbie and I just started reading  
the  
Little Book of Ruby. On page 22 it says that “the to\_s method is  
defined  
for the Object class itself”. If the Object class has no methods (as  
your  
irb session shows), then what exactly is meant by the Little Book of  
Ruby  
statement?
