You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The section on applying the splat operator in an argument list misses one important point. It says:
This technique works by sending :to_a to the prefixed object, so any object that responds to this message with an Array can be used in the same fashion.
However, it is important to note that splatting any object will work: if the prefixed object doesn't respond to #to_a, it is wrapped into a one-element array and then splatted, making the splat a no-op. The code for the splatarray bytecode in 1.9 is as follows:
VALUE tmp = rb_check_convert_type(ary, T_ARRAY, "Array", "to_a");
if (NIL_P(tmp)) {
tmp = rb_ary_new3(1, ary);
}
obj = tmp;
The text was updated successfully, but these errors were encountered:
The section on applying the splat operator in an argument list misses one important point. It says:
However, it is important to note that splatting any object will work: if the prefixed object doesn't respond to
#to_a
, it is wrapped into a one-element array and then splatted, making the splat a no-op. The code for thesplatarray
bytecode in 1.9 is as follows:The text was updated successfully, but these errors were encountered: