ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Subclassing Struct.new
by Minkoo Seo other posts by this author
Feb 28 2006 2:58AM messages near this date
Re: Formatting to "Thousands" | Re: Subclassing Struct.new
Hi group.

Please have a look at the following:

irb(main):001:0>  class F < Struct.new :n
irb(main):002:1>    def dec_n
irb(main):003:2>      n = n - 1
irb(main):004:2>    end
irb(main):005:1>  end
=>  nil
irb(main):006:0>  f = F.new 1
=>  #<struct F n=1>
irb(main):007:0>  f.dec_n
NoMethodError: undefined method `-' for nil:NilClass
        from (irb):3:in `dec_n'
        from (irb):7
        from :0
irb(main):008:0> 

I've tried to define a class which decrease n by 1, but failed. How can
I do that?

- Minkoo Seo
Thread:
Minkoo Seo
Chiaro Scuro
Minkoo Seo
Yukihiro Matsumoto
Mark Wilden
Markus Werner
Chiaro Scuro
Minkoo Seo
Minkoo Seo
Hal Fulton
mental
Ross Bamford
mental
Ross Bamford
Chiaro Scuro
Ross Bamford
Chiaro Scuro
Minkoo Seo
Chiaro Scuro
mental
Chiaro Scuro
mental
Yukihiro Matsumoto
Caleb Clausen
Yukihiro Matsumoto
Caleb Clausen
MenTaLguY
Yukihiro Matsumoto
gwtmp01
Chiaro Scuro
mental
Chiaro Scuro
mental
Logan Capaldo
Pit Capitain

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved