[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Concat is driving me crazy

Jay

11/7/2006 4:54:00 PM

This is driving me crazy. For some reason

product.title = "this is"
item.title = product.title.to_s << ' my string'

yields "this is my string"

but

product.title = "this is"
item.title = 'my string ' << product.title.to_s

will only yield "this is" without adding 'my string ' at the beginning.
I feel like there must be something incredibly simple I'm missing.
Advice would be much appreciated.

2 Answers

Jay

11/7/2006 5:12:00 PM

0

I found the answer: I'm a moron. Please disregard.

On Nov 7, 11:54 am, "Jay" <jay.janshe...@gmail.com> wrote:
> This is driving me crazy. For some reason
>
> product.title = "this is"
> item.title = product.title.to_s << ' my string'
>
> yields "this is my string"
>
> but
>
> product.title = "this is"
> item.title = 'my string ' << product.title.to_s
>
> will only yield "this is" without adding 'my string ' at the beginning.
> I feel like there must be something incredibly simple I'm missing.
> Advice would be much appreciated.

Tim Pease

11/7/2006 5:18:00 PM

0

On 11/7/06, Jay <jay.jansheski@gmail.com> wrote:
> This is driving me crazy. For some reason
>
> product.title = "this is"
> item.title = product.title.to_s << ' my string'
>
> yields "this is my string"
>
> but
>
> product.title = "this is"
> item.title = 'my string ' << product.title.to_s
>
> will only yield "this is" without adding 'my string ' at the beginning.
> I feel like there must be something incredibly simple I'm missing.
> Advice would be much appreciated.
>
>

What type of objects are _prodcut_ and _title_? Most likely the
unexpected behavior is happening in these objects.

If you could post some more code that is runnable by itself and
demonstrates the unexpected behavior, then an answer might be quicker
in the coming.

Blessings,
TwP