Quirky Curses behavior?

#!/usr/bin/env ruby

require ‘curses’
include Curses

i = 60

Works

puts (i / 60).to_s

Works

if (i % 60 == 0) then
puts (i / 60).to_s
end

Works

addstr (i / 60).to_s

Error: in `addstr’: can’t convert Fixnum to string

if (i % 60 == 0) then
addstr (i / 60).to_s
end

On Jul 21, 2006, at 12:18 AM, Eric A. wrote:

Works

end

try running your script like this:

ruby -w

I think you’ll notice something interesting is happening when it gets
to that line.

For those reading this thread who don’t want to take the time to
follow up on Logan Copaldo’s ( (excellent) suggestion, here is some
code contemplate. Parentheses matter.

Regards, Morton

#! /usr/bin/ruby -w

require ‘curses’
include Curses

init_screen
begin
i = 60
# Works
addstr((i / 60).to_s)
addstr("\n")
# Works
addstr((i / 60).to_s) if (i % 60 == 0)
addstr("\nPress any key to proceed: ")
refresh
getch
ensure
close_screen
end