On Fri, 5 Mar 2004 15:42:12 +0100, Yalin <kecik.yalin / siemens.com> wrote:

> I have installed ruby with "ruby181-11.exe" on Windows XP and wanted to 
> try
> some code samples from the Ruby Programmers Guide, but without success. 
> If I
> run following code, I don't get any output on console:
>
> ------------------------------------
>       a = [ 1, 'cat', 3.14 ]   # array with three elements
>       # access the first element
>       a[0]  ? 1
>       # set the third element
>       a[2] = nil
>       # dump out the array
>       a  ? [1, "cat", nil]
> ------------------------------------
>
> Just the command "puts a" works.
> Any idea?

The problem is that "a[0]  ? 1" in the Ruby Programmers Guide doesn't mean 
that "a[0]" prints "1", but merely that "1" is the result of the 
expression "a[0]". To actually see this result you'll have to print it 
with (for example) puts like this: "puts a[0]".
Another way is to use "irb" which will print out the result of everything 
you enter and therefore is a great enviromnent to try out these examples.

-- 
exoticorn/farbrausch