[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: {newb} file and puts
From:       "Jason Voegele" <jason () jvoegele ! com>
Date:       2004-10-12 19:58:46
Message-ID: 2093.192.146.101.26.1097611122.squirrel () std5 ! imagineis ! com
[Download RAW message or body]

James Edward Gray II said:
> On Oct 12, 2004, at 2:45 PM, STEPHEN BECKER I V wrote:
>
>> f="z:\t.txt"
>> loc = File.open(f, "w+")
>> loc.puts((i+65).chr,' ',a[i]) if a[i]>0
>>
>>
>> Nevermind what it is writing, How do i keep the (i+65).chr and a[i] on
>> the same line in the file?
>
> Use print() instead of puts() and insert \n characters as needed.

Alternatively, continue to use puts() and use string variable
interpolation instead of separate parameters. In other words:

  loc.puts("#{(i+65).chr} #{a[i]}") if a[i]>0

-- 
Jason Voegele
"There is an essential core at the center of each man and woman that
remains unaltered no matter how life's externals may be transformed
or recombined. But it's smaller than we think."
    -- Gene Wolfe, The Book of the Long Sun




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic