Question

If you do something as follows:

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) 

I want to do this, because I am currently working on a Facebook app, where I am doing this FQL query using Koala:

SELECT uid,name FROM user WHERE uid IN ( 11111119, 1022222255) 

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 11111119 & 1022222255 here.)

How can I print the values of the array inside () and not [].
Please let me know if anything is unclear and forgive me if the question is daft.

Was it helpful?

Solution

A simple way to do this would be:

array = [1, 2]
puts "Array when output in \"\" is (#{array.join(', ')})"

Since you're building a query, you'll want to be sure that each UID is purely numeric to prevent SQL-injection style attacks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top