-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[doc] join with undef values #22205
Comments
All string functions interpret their arguments as strings, with the exception of |
Thanks! |
The very first sentence:
Mentions both that list elements are treated as strings and that the return value is a string. |
I agree. The implication is that Ok, if I am the only person to find this description very terse and incomplete regarding "undefined", fell free to reject this issue. |
@hexcoder- The counter-question is, how could undefs be preserved in a string when all strings are defined? |
@guest20: when all strings are defined, there are obviously no undefs to be preserved. The motivation for this issue/question came from my "code review" of Line 2494 in 8cacb84
and the following line Line 2495 in 8cacb84
where the |
I think you missed the point of the question: strings are by definition defined, not in the argument list but in all of Perl. So when undef is passed to a function that takes strings, it is always interpreted as the empty string with a warning. |
Where
https://perldoc.perl.org/blead/functions/join as of 05/10/2024.
Description
join EXPR,LIST
F.e.:
my $rec = join(':', undef, undef);
does return ':' (with warnings).
What is missing in the documentation is that LIST items are stringified so that undefined values will be transformed to empty strings yielding the result of two empty string LIST items.
(In my first reading I overlooked the statement that
join
ALWAYS returns a string. So I assumed a single LIST item ofundef
would result in anundef
value).The text was updated successfully, but these errors were encountered: