in reply to Python 'is' command
use strict; use warnings; use Test::Simple tests => 2; sub is { use Scalar::Util qw(refaddr); return (refaddr $_[0] == refaddr $_[1]); } my $x = 3; my $y = 3; my $x_ref = \$x; my $test_ref_1 = \$x; my $test_ref_2 = \$y; ok( is($test_ref_1, $x_ref), 'Same' ); ok( !is($test_ref_2, $x_ref), 'Different' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Python 'is' command
by AnomalousMonk (Archbishop) on Aug 14, 2019 at 18:51 UTC | |
by haukex (Archbishop) on Aug 14, 2019 at 19:33 UTC | |
by AnomalousMonk (Archbishop) on Aug 15, 2019 at 02:43 UTC | |
by haukex (Archbishop) on Aug 15, 2019 at 06:46 UTC | |
by BillKSmith (Monsignor) on Aug 14, 2019 at 20:22 UTC | |
by bliako (Abbot) on Aug 14, 2019 at 21:17 UTC |