# AddRange problem

**URL:** <https://www.ruby-forum.com/t/addrange-problem/128516>\
**Category:** IronRuby\
**Created:** [February 8, 2008, 11:14am UTC](https://www.ruby-forum.com/t/addrange-problem/128516 "2008-02-08T11:14:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dermothogan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dermothogan](https://www.ruby-forum.com/u/dermothogan)\
**Post date:** [February 8, 2008, 11:14am UTC](https://www.ruby-forum.com/t/addrange-problem/128516/1 "2008-02-08T11:14:16Z")

</div>

I’m having trouble with this in a ListBox control:

self.listBox1.Items.AddRange([‘a’, ‘b’, ‘c’])

I get the error

:0:in `InitializeComponent': wrong number or type of arguments for`AddRange’ (ArgumentError)

What’s the correct syntax here?

(I think this used to work)

Dermot

---

<div class="post-metadata">

**Author:** ![dermothogan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dermothogan](https://www.ruby-forum.com/u/dermothogan)\
**Post date:** [February 8, 2008, 2:50pm UTC](https://www.ruby-forum.com/t/addrange-problem/128516/2 "2008-02-08T14:50:13Z")

</div>

For some reason it seems to be passing it in as

self.listBox1.Items.AddRange(‘a’, ‘b’, ‘c’)

Odd…

Regardless though, as a work around for now you can do this:

[‘a’,‘b’,‘c’].each {|item| self.listBox1.Items.Add item}

On Feb 8, 2008 5:14 AM, Dermot H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> (I think this used to work)
> 
> ## Dermot
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> Ironruby-core mailing list  
> removed\_email\_address@domain.invalid  
> [http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Michael L.  
[Polymath Programmer]  
[http://michaeldotnet.blogspot.com](http://michaeldotnet.blogspot.com)

---

<div class="post-metadata">

**Author:** ![dermothogan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dermothogan](https://www.ruby-forum.com/u/dermothogan)\
**Post date:** [February 8, 2008, 4:10pm UTC](https://www.ruby-forum.com/t/addrange-problem/128516/3 "2008-02-08T16:10:40Z")

</div>

Michael L. wrote:

> For some reason it seems to be passing it in as
> 
> self.listBox1.Items.AddRange(‘a’, ‘b’, ‘c’)
> 
> Odd…
> 
> Regardless though, as a work around for now you can do this:
> 
> [‘a’,‘b’,‘c’].each {|item| self.listBox1.Items.Add item}

Unfortunately I can’t do that … I have to use AddRange because that’s  
what the ListBox control + Form Designer generates. So I think I’m stuck  
☹

Dermot
