Logo

Programming-Idioms

History of Idiom 22 > diff from v75 to v76

Edit summary for version 76 by daxim:
[Perl] more verbose

Version 75

2019-09-27, 23:21:04

Version 76

2019-09-29, 17:47:30

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration
Extra Keywords
int base conversion
Extra Keywords
int base conversion
Code
my $i = $s + 0;
Code
my $i = $s + 0;
Comments bubble
Perl automatically converts numbers to strings, and strings to numbers, whenever required.

+ is addition, not concatenation.
Comments bubble
Perl automatically converts numbers to strings, and strings to numbers, whenever required. This means the addition of 0 is strictly superfluous, it only indicates programmer intent.

+ always is addition, not concatenation.