Skip to content

Commit 1da9525

Browse files
authored
Merge pull request #78 from leonerd/ppc0030-clarify-references
PPC0030: Clarify the behaviour of the operators when applied to references
2 parents 6ebea21 + 40537a5 commit 1da9525

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

ppcs/ppc0030-undef-aware-equality.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ $x equ $y
5353

5454
In particular, given two `undef` values, this operator will yield true. Given one `undef` and one defined value, it yields false, or given two defined values it will yield the same answer that `eq` would. In no circumstance will it provoke a warning of undefined values.
5555

56+
Like `eq`, it will stringify any reference value it receives; thus it may still consider that a reference is equal to a string that contains what the reference would stringify to:
57+
58+
```perl
59+
my $arr = [];
60+
$arr equ sprintf("ARRAY(0x%x)", $arr)
61+
```
62+
5663
Likewise, a new operator named `===`, which provides the numerical counterpart:
5764

5865
```perl
@@ -62,7 +69,7 @@ $x === $y
6269
# (defined $x and defined $y and $x == $y)
6370
```
6471

65-
Note that while the `===` operator will not provoke warnings about undefined values, it could still warn about strings that do not look like numbers.
72+
Note that while the `===` operator will not provoke warnings about undefined values, it could still warn about strings that do not look like numbers. And similarly, it will numify any reference value.
6673

6774
## Backwards Compatibility
6875

0 commit comments

Comments
 (0)