[MacRuby-devel] #init, or #initialize
Rob Gleeson
rob at flowof.info
Thu Feb 24 05:31:48 PST 2011
On 24 Feb 2011, at 13:26, Eloy Durán wrote:
> I use #init whenever I’m dealing with Cocoa(-like) classes and #initialize when it's pure Ruby. I do the same with regards to camel and snake casing. Also note that #init is not supposed to take arguments, whereas #initialize may definitely do so.
>
> Any classes that inherit from NSObject directly will have #initialize called if #init is called on them:
>
> % cat t.rb
> class PureRubyClass
> def initialize
> puts "here!"
> end
> end
>
> PureRubyClass.alloc.init
>
> % macruby t.rb
> here!
>
Alright, thanks for clarifying.
The camelCase and snake_case difference is something I've been trying to get use to as well. I think I'll adopt your style :)
--
Rob
More information about the MacRuby-devel
mailing list