def print_all(f)
puts f.read()
end
The return value of print_all
is the return value of puts f.read()
, which is the return value of puts
, not the return value of f.read()
. puts
always returns nil
. Therefore, print_all
always returns nil
.
Perhaps you intended:
def print_all(f)
f.read()
end
Or if you need to print it in your function/method:
def print_all(f)
foo = f.read()
puts foo
foo
end