IO.readlines should use keyword arguments

tenderlove edited this page Dec 10, 2012 · 1 revision

Overview

The class method IO.readlines method should be defined using keyword arguments. This will result in better error messages.

Examples

The readlines method can still be used normally:

IO.readlines("foo", $/, encoding: 'UTF-8') # => array

Unknown options will raise an exception:

IO.readlines("foo", $/, foo: 'UTF-8') # => unknown keyword: foo (ArgumentError)

Rationale

Today, users can pass unknown keys as options to IO.readlines. These options have no impact on reading the file. Most likely these unknown options are due to user error, so we should use keyword arguments so that users are alerted to the error.

Discussion

...