From: "Shota Fukumori (sora_h)" Date: 2011-01-12T08:35:34+09:00 Subject: [ruby-core:34391] Re: [Ruby 1.9-Feature#4264] General type coercion protocol for Ruby On Wed, Jan 12, 2011 at 2:10 AM, Rodrigo Rosenfeld Rosas wrote: > �Whatever what name is chosen, shouldn't we also define another method like > Object#from so that Object#to would be implemented as below? > > def to(klass) > � �klass.from(self) > end > > Rodrigo > > Em 11-01-2011 14:46, Haase, Konstantin escreveu: >> >> Both #as (Parslet, Sequel, MetaWhere, hacketyhack, Facets, Ruport, >> CouchPotato, ...) and #to (RSpec, Ramaze, ActiveSupport) are use in DSLs. >> However, I really prefer #to. >> >> Konstantin >> >> On Jan 11, 2011, at 17:39 , Rodrigo Rosenfeld Rosas wrote: > > > +1. Good Idea. * Object#to(klass, *args) * Class.from(obj, *args) ## "10".to(Integer) #=> 10 Integer.from("10") #=> 10 10.to(String, 8) #=> "12" String.from(10, 8) #=> "12" ## -- Shota Fukumori a.k.a. @sora_h - http://codnote.net/