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

Fix #210 Recreate Ruby's line breaks in Puts #211

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/testup/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,15 @@ def puts(*args)
if args.empty?
write $/
else
for arg in args
line = arg.to_s
write(line)
if line.empty? || !line.end_with?($/)
write($/)
for arg in args # Why not 'args.each do |arg|' ?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also wondering if there's a reason for using for. each seems more common but I don't think there is any difference other than cosmetic here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That probably stems back to when for was faster than each.

if arg.is_a?(Array)
arg.each { |e| puts(e) }
else
line = arg.to_s
write(line)
if line.empty? || !line.end_with?($/)
write($/)
end
end
end
end
Expand Down