SciRuby / rubex

rubex - A Ruby-like language for writing Ruby C extensions.
BSD 2-Clause "Simplified" License
451 stars 21 forks source link

Print not working correctly in irb #6

Open lokeshh opened 7 years ago

lokeshh commented 7 years ago

Using the Fibonnaci code in the README

lokeshh:~/workspace/rubex/fib $ irb
2.3.0 :001 > require_relative 'fib.so'
 => true 
2.3.0 :002 > Fibonnaci.new.compute(10)
 => false 
2.3.0 :003 > quit
1"\n"1"\n"2"\n"3"\n"5"\n"8"\n"13"\n"21"\n"34"\n"55"\n"89"\n"lokeshh:~/workspace/rubex/fib $ 

So, its printing the all the output when I quit irb.

v0dro commented 7 years ago

Nice find! print works with printf() underneath so it prints out to C's STDOUT and not Ruby's STDOUT.

Having a separate statement puts that works with Ruby's STDOUT should fix the problem.