Actions
Bug #13336
closedDefault Parameters don't work
Description
def funny(a = true, b: nil)
p a
end
funny([1,2,3]) # => [1,2,3]
funny({k:1}) # => in `funny': unknown keyword: k (ArgumentError)
Files
Updated by ko1 (Koichi Sasada) over 7 years ago
- Assignee set to mame (Yusuke Endoh)
mame-san: what do you think about it?
Updated by nobu (Nobuyoshi Nakada) over 7 years ago
- Description updated (diff)
- Assignee deleted (
mame (Yusuke Endoh))
Updated by mame (Yusuke Endoh) over 7 years ago
This is intended. If a method accepts keyword arguments and if its last argument is a hash object, it is considered for keyword arguments. If you want to pass a hash as the first parameter, you need to explicitly pass a hash for keyword arguments, i.e., funny({k: 1}, {})
.
Updated by hsbt (Hiroshi SHIBATA) almost 7 years ago
- Related to Feature #14183: "Real" keyword argument added
Updated by marcandre (Marc-Andre Lafortune) about 6 years ago
- Status changed from Open to Closed
This is a duplicate of #12717, so closing this.
Updated by marcandre (Marc-Andre Lafortune) about 6 years ago
- Is duplicate of Bug #12717: Optional argument treated as kwarg added
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0