Plus, the %<char> sigil syntax is a conversion operation on a string literal (and following the percent sign immediately by a paired closure, e.g., %["Let's make s'mores", Cathy said] creates an interpolated string literal where neither the " nor ' characters need to be escaped). It's a clever idea, but it would be a nontrivial amount of reworking to have MRI begin treating the enclosed contents of this syntax as a discrete set of typed data for the case of a Set object.
I might as well also say it here, to avoid double-commenting: The block syntax as you have it written in
[1,2,3].any?{1}
would return true even if you called #all? with that block, as the expression evaluates to a truthy value (an instance of Numeric), not as a value against which each value should be compared
Regarding this, yes, that was the point of that example. It's ambiguous. Is it a set? Is it a block? For me I know it'll probably be called a block but it's an edge case to watch out for.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Plus, the
%<char>
sigil syntax is a conversion operation on a string literal (and following the percent sign immediately by a paired closure, e.g.,%["Let's make s'mores", Cathy said]
creates an interpolated string literal where neither the"
nor'
characters need to be escaped). It's a clever idea, but it would be a nontrivial amount of reworking to have MRI begin treating the enclosed contents of this syntax as a discrete set of typed data for the case of a Set object.I might as well also say it here, to avoid double-commenting: The block syntax as you have it written in
would return
true
even if you called#all?
with that block, as the expression evaluates to a truthy value (an instance ofNumeric
), not as a value against which each value should be comparedRegarding this, yes, that was the point of that example. It's ambiguous. Is it a set? Is it a block? For me I know it'll probably be called a block but it's an edge case to watch out for.