Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > "wrong number of arguments" What? I must be thick or somethi

Reply
Thread Tools

"wrong number of arguments" What? I must be thick or somethi

 
 
ole __
Guest
Posts: n/a
 
      01-03-2008
class PermutationIterator
def initalize(data_set, nested = nil)
@data_set = data_set
@nested = nested || NilObject.new
@key = 0
@fresh = true
end
end
a = PermutationIterator.new [1, 2, 3]

Will yield:

permutations.rb:9:in `initialize': wrong number of arguments (1 for 0)
(ArgumentError)
from permutations.rb:9:in `new'
from permutations.rb:9

What am I doing wrong?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
steffen_kory@wowway.com
Guest
Posts: n/a
 
      01-03-2008
I think there is a typo: "def initalize"


On Fri, 4 Jan 2008 00:39:26 +0900, ole __ wrote
> class PermutationIterator
> def initalize(data_set, nested = nil)
> @data_set = data_set
> @nested = nested || NilObject.new
> @key = 0
> @fresh = true
> end
> end
> a = PermutationIterator.new [1, 2, 3]
>
> Will yield:
>
> permutations.rb:9:in `initialize': wrong number of arguments (1 for 0)
> (ArgumentError) from permutations.rb:9:in `new' from

permutations.rb:9
>
> What am I doing wrong?
> --
> Posted via http://www.ruby-forum.com/.



 
Reply With Quote
 
 
 
 
Frederick Cheung
Guest
Posts: n/a
 
      01-03-2008

On 3 Jan 2008, at 15:39, ole __ wrote:

> class PermutationIterator
> def initalize(data_set, nested = nil)
> @data_set = data_set
> @nested = nested || NilObject.new
> @key = 0
> @fresh = true
> end
> end
> a = PermutationIterator.new [1, 2, 3]
>
> Will yield:
>
> permutations.rb:9:in `initialize': wrong number of arguments (1 for 0)
> (ArgumentError)
> from permutations.rb:9:in `new'
> from permutations.rb:9
>
> What am I doing wrong?

You've typoed initalize

Fred
>
> --
> Posted via http://www.ruby-forum.com/.
>



 
Reply With Quote
 
Tiago Macedo
Guest
Posts: n/a
 
      01-03-2008
Hi,

You mistyped initialize.

Tiago Macedo

ole __ wrote:
> class PermutationIterator
> def initalize(data_set, nested = nil)
> @data_set = data_set
> @nested = nested || NilObject.new
> @key = 0
> @fresh = true
> end
> end
> a = PermutationIterator.new [1, 2, 3]
>
> Will yield:
>
> permutations.rb:9:in `initialize': wrong number of arguments (1 for 0)
> (ArgumentError)
> from permutations.rb:9:in `new'
> from permutations.rb:9
>
> What am I doing wrong?


 
Reply With Quote
 
ole __
Guest
Posts: n/a
 
      01-03-2008
Ahh right. I needed somebody else's eyes to see that.
Thanks
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Hugh Themm
Guest
Posts: n/a
 
      01-03-2008
NilObject does not have a method called new.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Rick DeNatale
Guest
Posts: n/a
 
      01-03-2008
On Jan 3, 2008 11:16 AM, Hugh Themm <(E-Mail Removed)> wrote:
> NilObject does not have a method called new.


Yes, but he hadn't gotten to that point yet.

@nested = nested || NilObject.new

won't work, and is probably unnecessary.

@nested = nested

is probably enough, unless you really want to be able to pass false to
indicate no nested, which would be a strange interface for a ruby
method I think. But it that's what's actually desired, it should be

@nested = nested || nil



--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

 
Reply With Quote
 
ole __
Guest
Posts: n/a
 
      01-04-2008
> Yes, but he hadn't gotten to that point yet.

Right. And I only posted a cut down version of the code. NilObject is
defined in the full version.

> @nested = nested || NilObject.new
>
> won't work, and is probably unnecessary.


Interesting. Let me make certain you understand my intentions first.
NilObject looks like this:

class NilObject
def method_missing(name, *params); end
end

It just swallows messages. It is an implementation of the Introduce Null
Object refactor
http://www.refactoring.com/catalog/i...ullObject.html This means
that I don't have to continuously repeat checks for nil. It's explained
a bit better here
http://www.industriallogic.com/xp/re...ullObject.html

This is a concept that has come straight out of Java so I'm interested
if there is a more ruby way of doing such things.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Julix Andres
Guest
Posts: n/a
 
      08-13-2008
That is the solution
Run
# ruby script/generate scaffold Product Admin:string

instead of
# ruby script/generate scaffold Product Admin


Blessings
http://www.velocityreviews.com/forums/(E-Mail Removed)
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Oliver Saunders
Guest
Posts: n/a
 
      08-14-2008
Julix Andres wrote:
> That is the solution
> Run
> # ruby script/generate scaffold Product Admin:string
>
> instead of
> # ruby script/generate scaffold Product Admin
>
>
> Blessings
> (E-Mail Removed)


I think you must have replied to the wrong thread or something.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
draw thick line without using Graphics2D SPG Java 2 02-15-2005 02:46 PM
Thick Client Portal Framework Mango Java 0 01-09-2005 01:11 AM
Thin client to thick client communication Russ ASP .Net 1 11-29-2004 06:44 PM
Re: Web enabled App architecture question - thin or thick client? Benoit Java 0 08-11-2004 09:39 AM
Web enabled App architecture question - thin or thick client? Adam Lipscombe Java 5 04-24-2004 08:09 AM



Advertisments