jashkenas / ruby-processing

Code as Art, Art as Code. Processing and Ruby are meant for each other.

Home Page:http://github.com/jashkenas/ruby-processing/wikis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'println 1' does not print anything

awarua opened this issue · comments

Noticed this when trying ex 04_08 from the Processing handbook in ruby...

  println 4/3        # Should print "1"                                                 
  println 4.0/3      # Should print "1.3333334"                                         
  println 4/3.0      # Should print "1.3333334"                                         
  println 4.0/3.0    # Should print "1.3333334"      

...but the output is not as expected:

1.3333334
1.3333334
1.3333334

It prints a blank line instead of '1' for println 4/3. Does the same if you pass println an integer

println 1    # Prints a blank line
println 2    # Prints a blank line

puts 4/3 works like you'd expect...

Really!
Surely only a pedant would want that behaviour, but it can be achieved if you really must:-

$app.java_send :println, [Java::int], 4/3 # Should print "1"
$app.java_send :println, [Java::float], 4.0/3 # Should print "1.3333334"
$app.java_send :println, [Java::float], 4/3.0 # Should print "1.3333334"
$app.java_send :println, [Java::float], 4.0/3.0 # Should print "1.3333334"

Which I think only goes to show how you are "mistaken". How the hell you got blank lines god only knows.

@awarua What do you think?

uninformative