# Problems using a string as an option

**URL:** <https://www.ruby-forum.com/t/problems-using-a-string-as-an-option/121576>\
**Category:** Rails\
**Created:** [November 29, 2007, 12:25am UTC](https://www.ruby-forum.com/t/problems-using-a-string-as-an-option/121576 "2007-11-29T00:25:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@jay](https://www.ruby-forum.com/u/jay)\
**Post date:** [November 29, 2007, 12:25am UTC](https://www.ruby-forum.com/t/problems-using-a-string-as-an-option/121576/1 "2007-11-29T00:25:44Z")

</div>

Hello Group,

I’ve tried various ways to solve my problem with no luck.  
I have a loop that creates a string based upon a database

@markerstring \<\< “#{spot.id} =\> @markers[#{spot.id}]”

this creates the correct string  
I am then using the ym4r library([http://thepochisuperstarmegashow.com/](http://thepochisuperstarmegashow.com/)  
ProjectsDoc/ym4r\_gm-doc/) to create a markergroup with a function  
that creates some javascript.

Like so,

@map.overlay\_global\_init(GMakerGroup.new(true,@markerstring),“MyGroup”)

^^^^ This doesn’t work but the following does:

@map.overlay\_global\_init(GMakerGroup.new(true, 1 =\> @markers[1],2 =\>  
@markers[2]),“MyGroup”)

so I’m assuming that it is passing “@markerstring” rather than the  
contents of the VAR @markersting as an option, thus the operation  
fails…

Any ideas what I’m doing wrong? Or how I can dynamically compile a  
options string???

Thanks!

---

<div class="post-metadata">

**Author:** ![jay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@jay](https://www.ruby-forum.com/u/jay)\
**Post date:** [November 29, 2007, 5:24pm UTC](https://www.ruby-forum.com/t/problems-using-a-string-as-an-option/121576/2 "2007-11-29T17:24:03Z")

</div>

On Nov 28, 2007 5:25 PM, Jay [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> @map.overlay\_global\_init(GMakerGroup.new(true,@markerstring),“MyGroup”)

I’m not sure what you’re trying to do exactly but usually you pass a  
hash to new(), something like:

GMakerGroup.new( :foo =\> true, :bar =\> @markerstring )

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![jay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@jay](https://www.ruby-forum.com/u/jay)\
**Post date:** [November 29, 2007, 8:19pm UTC](https://www.ruby-forum.com/t/problems-using-a-string-as-an-option/121576/3 "2007-11-29T20:19:31Z")

</div>

Basically I’m wondering why

@string = “:foo =\> true, :bar =\>@markerstring”

GMakerGroup.new(@string)

is not equal to

GMakerGroup.new( :foo =\> true, :bar =\> @markerstring )

that is all, why is my string being interpreted as “@string” rather  
than its contents???

---

<div class="post-metadata">

**Author:** ![jay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@jay](https://www.ruby-forum.com/u/jay)\
**Post date:** [November 29, 2007, 10:25pm UTC](https://www.ruby-forum.com/t/problems-using-a-string-as-an-option/121576/4 "2007-11-29T22:25:36Z")

</div>

On 29 Nov 2007, at 19:18, Jay wrote:

> that is all, why is my string being interpreted as “@string” rather  
> than its contents???

Strings aren’t hashes. There is no “interpretation” going on when you  
pass @string to GMakerGroup, it’s just a string  
There’s no reason why those 2 things should be equivalent.

Fred
