Bug #18771
Updated by andrykonchin (Andrew Konchin) about 3 years ago
The `IO.readlines` method has the following signature: ``` readlines(name, sep, limit [, getline_args, open_args]) → array ``` The last arguments `getline_args`, `open_args` are accepted as keyword arguments, so there are actually 3 positioned arguments - `name`, `sep`, and `limit`. But if the method is called with any 4th positional positioned argument - then it's just ignored. But I would expect an exception to be raised e.g. "ArgumentError: wrong number of arguments (given 4, expected 1..3)" ```ruby File.readlines('file.txt', "\n", 10) => ["abc\n", "\n", "def\n"] File.readlines('file.txt', "\n", 10, {}) => ["abc\n", "\n", "def\n"] File.readlines('file.txt', "\n", 10, {chomp: true}) => ["abc\n", "\n", "def\n"] File.readlines('file.txt', "\n", 10, false) => ["abc\n", "\n", "def\n"] File.readlines('file.txt', "\n", 10, nil) => ["abc\n", "\n", "def\n"] ``` It's relevant to the `IO.foreach` method as well. Expected behavior - an ArgumentError exception to be raised.