On Oct 30, 7:11 am, Chris Richards <evilgeen... / gmail.com> wrote:
> Is there a better way to write text to a file?
>
> File.open("/file/location/new.txt","w") {|file| file.write "data to
> write"}
>
> It just seems a bit long winded and unmessy

What would you prefer?

Ruby is quite flexible, so if you start with how you'd like it to
work, you can probably get close. For example (I'm not recommending
these, but if you're looking for brief):

w "/tmp/foo.txt","data to write"

or

"data to write".w "/tmp/foo.txt"

or

"/tmp/foo.txt".w "data to write"