Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help with something very simple

44 views
Skip to first unread message

Jatin Ganhotra

unread,
Mar 21, 2013, 11:39:32 AM3/21/13
to
Hi,

1.9.3p194 :005 > array = [ 1, 2]
=> [1, 2]
1.9.3p194 :007 > puts "Array when output in \"\" is #{array}"
Array when output in "" is [1, 2]
=> nil

Can I do something, so that the output is:
Array when output in "" is (1, 2)

If you want to know why I want to do this, please read further:

I am currently working on a Facebook app, where I am doing this FQL query:

SELECT uid,name FROM user WHERE uid IN ( 1808606809, 100000255371755)

The above FQL query works fine in Graph API Explorer provided by Facebook.
However, in my app source code, I have an array of such UID's (e.g 1808606809 and 100000255371755 here.)

To do the query, If I pass #{array_of_ids} inside the "", it doesn't work. Hence, I need it to be inside "()" and not "[]".

Christian Neukirchen

unread,
Mar 21, 2013, 12:55:30 PM3/21/13
to
Jatin Ganhotra <jatin.g...@gmail.com> writes:

> Hi,
>
> 1.9.3p194 :005 > array = [ 1, 2]
> => [1, 2]
> 1.9.3p194 :007 > puts "Array when output in \"\" is #{array}"
> Array when output in "" is [1, 2]
> => nil

>> puts "Array when output in \"\" is (#{array.join(', ')})"

> Can I do something, so that the output is:
> Array when output in "" is (1, 2)

--
Christian Neukirchen <chneuk...@gmail.com> http://chneukirchen.org

Jatin Ganhotra

unread,
Mar 21, 2013, 1:18:09 PM3/21/13
to
Thanks @Christian. It worked like a charm.

Robert Klemme

unread,
Mar 21, 2013, 5:23:54 PM3/21/13
to
On 21.03.2013 18:18, Jatin Ganhotra wrote:
> Thanks @Christian. It worked like a charm.

Make sure though that you check what's in the Array to avoid SQL
injection attacks!

Kind regards

robert


--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
0 new messages