# Traits-1.9.1 released

**URL:** <https://www.ruby-forum.com/t/traits-1-9-1-released/135770>\
**Category:** Ruby\
**Created:** [April 24, 2008, 8:07pm UTC](https://www.ruby-forum.com/t/traits-1-9-1-released/135770 "2008-04-24T20:07:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flatekmonkey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e8c25b/32.png) [@flatekmonkey](https://www.ruby-forum.com/u/flatekmonkey)\
**Post date:** [April 24, 2008, 8:07pm UTC](https://www.ruby-forum.com/t/traits-1-9-1-released/135770/1 "2008-04-24T20:07:57Z")

</div>

Hi list

motivated by a recent discussion on this list and in order to be  
functionally compatible with #is\_a? for modules I have added  
Object#behaves\_like?. I did not want to overload Object#is\_a? because  
traits do not really semantically provide the notion of inheritance.  
An important difference to is\_a? or Module#=== is that  
Object#behaves\_like? will always reflect the current state of the  
object and the trait in question even if they were  
dynamically changed.

E.g.  
t = trait {  
message :a do :a end  
}  
o = t.to\_object  
t.message :b do :b end  
o.behaves\_like? t # → false  
class \<\< o  
def b; 42 end  
end  
o.behaves\_like? t # → true

You can use Object#behaves\_like? with all objects that respond to a  
message get\_message\_names  
if it returns an Enumerable yielding strings and symbols to #each, but  
of course it is primarily  
designed for traits ;).

Enjoy  
Robert

[http://rubyforge.org/frs/?group\_id=4642](http://rubyforge.org/frs/?group_id=4642)
