Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print not working correctly in irb #6

Open
lokeshh opened this issue Aug 17, 2017 · 1 comment
Open

Print not working correctly in irb #6

lokeshh opened this issue Aug 17, 2017 · 1 comment

Comments

@lokeshh
Copy link
Member

lokeshh commented Aug 17, 2017

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
Copy link
Member

v0dro commented Aug 18, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants