[Rubycocoa-devel 792] Re: Minor issue with self.privateMethod

Back to archive index

brian hammond bhamm****@yahoo*****
Thu Mar 1 01:01:58 JST 2007


irb(main):001:0> class A
irb(main):002:1> def initialize
irb(main):003:2>   self.foo
irb(main):004:2> end
irb(main):005:1> private
irb(main):006:1> def foo
irb(main):007:2>   puts "hi"
irb(main):008:2> end
irb(main):009:1> end
=> nil
irb(main):010:0> A.new
NoMethodError: private method `foo' called for #<A:0x7e02c>
        from (irb):3:in `initialize'
        from (irb):10:in `new'
        from (irb):10
        from :0

irb(main):011:0> class A
irb(main):012:1> def initialize
irb(main):013:2>   foo
irb(main):014:2> end
irb(main):015:1> private
irb(main):016:1> def foo
irb(main):017:2>   puts "hi"
irb(main):018:2> end
irb(main):019:1> end
=> nil
irb(main):020:0> A.new
hi

 
- Brian

----- Original Message ----
From: Jacob Wallström <jacob****@ghost*****>
To: rubyc****@lists*****
Sent: Wednesday, February 28, 2007 10:53:30 AM
Subject: [Rubycocoa-devel 791] Minor issue with self.privateMethod

I discovered that the following won't work using Rubycocoa-unstable  
(revision 1600).

class MyClass < OSX::NSObject

    def publicMethod
        self.privateMethod # gives error method not found
        privateMethod        # works
    end

    private

    def privateMethod
    end
end

Since it is valid to call private methods in ruby using the self  
notation, I think it should work in RubyCocoa too.

Best regards,
Jacob Wallström
http://ghostparksoftware.com


_______________________________________________
Rubycocoa-devel mailing list
Rubyc****@lists*****
http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel





 
____________________________________________________________________________________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/



More information about the Rubycocoa-devel mailing list
Back to archive index