jashkenas / ruby-processing

Code as Art, Art as Code. Processing and Ruby are meant for each other.
http://github.com/jashkenas/ruby-processing/wikis
Other
1.28k stars 94 forks source link

'println 1' does not print anything #48

Closed jareddonovan closed 11 years ago

jareddonovan commented 12 years ago

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...

monkstone commented 11 years ago

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?

monkstone commented 11 years ago

uninformative