views:

27

answers:

1

I have a simple Ruby program which takes the command line arguments and posts them to a server.

However, I want to be able to write the # (pound, hash symbol) in my arguments without ruby trying to parse it. I'm not so familiar with Ruby. I know I can pass the arg with quotes, but I would like to know if it's possible without them.

ARGV.each do |a|
    s = '' + a
    puts "Argument: #{s}"
end

The above doesn't work. Maybe something with gsub?

+2  A: 

Just like this

puts "Argument: ##{s}"

#is special in " " only when it meets {}. Otherwise, it shows #.

OmniBus
On my (Windows) system, that just displays two hashes: 'Argument: ##himum'
Grant Crofton