# Trying to squeeze a variable in here =\>

**URL:** <https://www.ruby-forum.com/t/trying-to-squeeze-a-variable-in-here/125770>\
**Category:** Ruby\
**Created:** [January 11, 2008, 9:42pm UTC](https://www.ruby-forum.com/t/trying-to-squeeze-a-variable-in-here/125770 "2008-01-11T21:42:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [January 11, 2008, 9:42pm UTC](https://www.ruby-forum.com/t/trying-to-squeeze-a-variable-in-here/125770/1 "2008-01-11T21:42:15Z")

</div>

Hi Ruby…

I have an SNMP command that I’m using which works fine in my script:

There is a static portion that needs to be changed so I can feed in the  
variable and it’s a bit tricky. I have tried every combination of " "  
and ’ ’ that I can think of and nothing works.  
Here is the line of code that works:

```
   response = m.get (["ifInOctets.1"])

```

The number “1” in the above piece of code needs to be changed to a  
variable.

Any ideas on how to squeeze a variable in there?

thanks

jackster.mobi

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [January 11, 2008, 10:17pm UTC](https://www.ruby-forum.com/t/trying-to-squeeze-a-variable-in-here/125770/2 "2008-01-11T22:17:06Z")

</div>

Alle venerdÃ¬ 11 gennaio 2008, jackster the jackle ha scritto:

> The number “1” in the above piece of code needs to be changed to a  
> variable.
> 
> Any ideas on how to squeeze a variable in there?
> 
> thanks
> 
> jackster.mobi

Use string interpolation:

response = m.get(["ifInOctets.#{number}])

Stefano

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [January 11, 2008, 11:13pm UTC](https://www.ruby-forum.com/t/trying-to-squeeze-a-variable-in-here/125770/3 "2008-01-11T23:13:22Z")

</div>

Stefano C. wrote:

> Alle venerdÃ¬ 11 gennaio 2008, jackster the jackle ha scritto:
> 
> > The number “1” in the above piece of code needs to be changed to a  
> > variable.
> > 
> > Any ideas on how to squeeze a variable in there?
> > 
> > thanks
> > 
> > jackster.mobi
> 
> Use string interpolation:
> 
> response = m.get(["ifInOctets.#{number}])
> 
> Stefano

that did the trick…thanks alot for the help on that Stefano

jackster.mobi
