Skip to content
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

tell difference in interaction of Nil in default params and default values #1669

Closed
gfldex opened this issue Nov 10, 2017 · 2 comments
Closed
Labels
docs Documentation issue (primary issue type)

Comments

@gfldex
Copy link
Contributor

gfldex commented Nov 10, 2017

sub f($a is raw = 42){ my $b is default('answer'); $b = True; $b = $a; say $b }; f Nil;
# rakudo-moar d6cd0d2f5: OUTPUT: «answer␤»
@tisonkun
Copy link
Member

@coke coke added the docs Documentation issue (primary issue type) label Jan 17, 2018
@JJ
Copy link
Contributor

JJ commented Sep 13, 2018

f Nil does not activate the default 42 value. Passing nothing does:

sub f($a is raw = 42 ){ my $b is default('answer'); $b =  $a; say $b }; f; # OUTPUT: «42␤»

$a will take a Nil value even if it's not declared as raw:

sub f($a){ my $b is default('answer'); say $a; $b = $a; say $b }; f Nil; # OUTPUT: «Nil␤answer␤»

I'll see how this can be explained better, maybe in Signatures.

@JJ JJ closed this as completed in 5fcaa5e Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation issue (primary issue type)
Projects
None yet
Development

No branches or pull requests

4 participants