Project

General

Profile

Actions

Bug #10582

closed

String#chomp strips off more newlines than its documentation states

Added by javawizard (Alex Boyd) about 10 years ago. Updated almost 10 years ago.

Status:
Closed
Assignee:
Target version:
ruby -v:
ruby 2.2.0dev (2014-12-04 trunk 48708) [x86_64-darwin14]
[ruby-core:66753]

Description

Given an empty string as its parameter, String#chomp strips off as many trailing newlines as are present, plus a preceding carriage return if one exists:

irb(main):001:0> "foo\n\n\n".chomp
=> "foo\n\n"
irb(main):002:0> "foo\n\n\n".chomp ''
=> "foo"
irb(main):003:0> "foo\r\n\n\n".chomp ''
=> "foo"

This should either be mentioned as part of String#chomp's documentation, or removed.


Files

780.patch (1.79 KB) 780.patch hsbt (Hiroshi SHIBATA), 01/27/2015 12:20 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0