Am Dienstag 14 Juli 2009 18:02:19 schrieb James Byrne:
>   def start
>       puts @argv.class
>       puts @argv.size
>       puts @argv
>       @argv.include?('--update') ? puts("Includes update") : puts("No
> --update")
>    ...
>
> which produces this output for a given input:
>
> Array
> 4
> '-s /doc/data/fx-noon-all-2009-04-15.xml'
> '-f csv'
> '-o forex_testing'
> '--update'
> '-t'
> No --update
>
> Now. Here are the posers that I cannot answer.
>
> Why is #size == 4 rather than 5; and

arr = ["1", "2", "3\n4", "5"]
puts arr
puts "size is #{arr.size}"

will output:
1
2
3
4
5
size is 4

Meaning: if some of the strings in the array contain newlines, you can not 
tell from puts' output how many items are in the array.

> Why is '--update' listed when printing the array but it is not found in
> the same array by #include?('--update'). What is it that I am getting
> wrong here?

puts ["--update"]
will output:
--update

puts ["'--update'"]
will output:
'--output'

In other words, puts will only surround the string with quotes if the string 
actually contains quotes.
Generally you should use p instead of puts for your debug output so you can 
more easily tell the exact contents of the array.

HTH,
Sebastian