# Urgent help required#\<NoMethodError:

**URL:** <https://www.ruby-forum.com/t/urgent-help-required-nomethoderror/196179>\
**Category:** Ruby\
**Created:** [October 8, 2010, 2:03am UTC](https://www.ruby-forum.com/t/urgent-help-required-nomethoderror/196179 "2010-10-08T02:03:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![datulravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c37758/32.png) [@datulravi](https://www.ruby-forum.com/u/datulravi)\
**Post date:** [October 8, 2010, 2:03am UTC](https://www.ruby-forum.com/t/urgent-help-required-nomethoderror/196179/1 "2010-10-08T02:03:50Z")

</div>

prompts5 = [“Span type”]  
defaults5 = [“1. Simply supported”]  
@t\_slab = [“1. Simply supported |2. Interior span |3. End span |4.  
Cantilever”]  
list5 = [@t\_slab]  
title5=“Please select the type of the span”  
@input\_tslab = inputbox prompts5, defaults5, list5,title5

kay\_array = [1.0, 1.5, 1.3, 0.4]  
@ka = kay\_array[(@input\_tslab).to\_i-1]

If “3. End span” is selected by in the UI, following error is  
displayed…

Error: #\<NoMethodError: undefined method `to\_i’ for ["3. End span  
"]:Array\>

---

<div class="post-metadata">

**Author:** ![datulravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c37758/32.png) [@datulravi](https://www.ruby-forum.com/u/datulravi)\
**Post date:** [October 8, 2010, 9:13am UTC](https://www.ruby-forum.com/t/urgent-help-required-nomethoderror/196179/2 "2010-10-08T09:13:35Z")

</div>

On Fri, Oct 8, 2010 at 2:05 AM, Atul D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> If “3. End span” is selected by in the UI, following error is  
> displayed…
> 
> Error: #\<NoMethodError: undefined method `to\_i’ for ["3. End span  
> "]:Array\>

Without knowing what inputbox does, it seems from the error message  
that it’s returning an Array. If you are sure that what you are after  
is in the first position of the array, you could do:

@ka = kay\_array[@input\_tslab.first.to\_i-1]

Jesus.

---

<div class="post-metadata">

**Author:** ![datulravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c37758/32.png) [@datulravi](https://www.ruby-forum.com/u/datulravi)\
**Post date:** [October 10, 2010, 3:37am UTC](https://www.ruby-forum.com/t/urgent-help-required-nomethoderror/196179/3 "2010-10-10T03:37:19Z")

</div>

On Thu, Oct 7, 2010 at 7:05 PM, Atul D.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> If “3. End span” is selected by in the UI, following error is  
> displayed…
> 
> ## Error: #\<NoMethodError: undefined method `to\_i’ for ["3. End span "]:Array\>
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

I assume you are using Google sketchup, and you are invoking this method  
[Homepage | SketchUp Developer](http://code.google.com/apis/sketchup/docs/ourdoc/ui.html#inputbox) If so,  
you  
can see they say that it returns nil or an Array, so @input\_tslab would  
be  
an Array. Then, you call (@input\_tslab).to\_i, first of all, you do not  
need  
parentheses, they don’t do anything. Second, that means you are invoking  
the  
to\_i method on the array that @input\_tslab has received from the  
inputbox  
method. But to\_i is not a method that Arrays have (  
[class Array - RDoc Documentation](http://ruby-doc.org/core/classes/Array.html)).

You need to figure out explicitly what will be returned (ie what does  
this  
Array actually contain? I know nothing about sketchup, so can only guess  
that it is the text contents of the inputbox – if it even has a  
textbox.)  
And then you need to figure out what you want to do with it. In this  
case,  
it looks like you want to associate it with a number. Figure out how to  
get  
from what is returned to the desired number. In your particular example,  
it  
looks like saying @input\_tslav.first.to\_i will work, but this might be a  
shaky solution, I’d expect if you get more familiar with the API this  
will  
be easier for you.

Also, make sure to handle the situation where the user cancels the box,  
and  
nil is returned.
