Subject: | 2 Possible logic errors in example |
The example below appears to over-write the "date_of_last_login", so ends up returning the current date (which is the date of this login, not the "date of last login"). It also ignores the results of the login.
use User;
my $user = User->new(
first_name => 'Example',
last_name => 'User',
password => 'letmein',
);
$user->login('letmein');
say $user->date_of_last_login;
my guess at the fix would be this:-
use User;
my $user = User->new(
first_name => 'Example',
last_name => 'User',
password => 'letmein',
);
my $last_login = $user->date_of_last_login;
if($user->login('letmein')) {
say $last_login;
}