On Mon, Oct 08, 2001 at 03:23:22PM +0200, Bart Lateur wrote:
> On Sat, 6 Oct 2001 19:48:13 -0400, Michael G Schwern wrote:
>
> >> What about zero.
> >
> >No problem in Perl 6.
> >
> >my $foo = %hash{foo} // 'some default';
>
> And nobody will ever confuse this operator with the "comment till
Bart Lateur wrote:
> On Sat, 6 Oct 2001 19:48:13 -0400, Michael G Schwern wrote:
>
> >> What about zero.
> >
> >No problem in Perl 6.
> >
> >my $foo = %hash{foo} // 'some default';
>
> And nobody will ever confuse this operator with the "comment till end of
> line" marker in C++, Java and Jav
On Sat, 6 Oct 2001 19:48:13 -0400, Michael G Schwern wrote:
>> What about zero.
>
>No problem in Perl 6.
>
>my $foo = %hash{foo} // 'some default';
And nobody will ever confuse this operator with the "comment till end of
line" marker in C++, Java and Javascript, and many more I suppose.
--
On Sun, Oct 07, 2001 at 01:26:53AM +0200, Bart Lateur wrote:
> > my $foo = $hash{foo} || 'some default';
> > my $bar = $hash{bar} || 'some other default';
>
> What about zero.
No problem in Perl 6.
my $foo = %hash{foo} // 'some default';
--
Michael G. Schwern <[EMAIL PROTECTED]>
On Fri, 28 Sep 2001 21:27:48 +0200, Johan Vromans wrote:
>Michael G Schwern <[EMAIL PROTECTED]> writes:
>
>> so if $key does not exist you'll get 'some default' instead of undef.
>
>Except that a more common case is
>
> my $foo = $hash{foo} || 'some default';
> my $bar = $hash{bar} || 'some oth
Michael G Schwern <[EMAIL PROTECTED]> writes:
> so if $key does not exist you'll get 'some default' instead of undef.
Except that a more common case is
my $foo = $hash{foo} || 'some default';
my $bar = $hash{bar} || 'some other default';
-- Johan
At 10:06 PM 9/24/2001 -0400, Michael G Schwern wrote:
>Wouldn't it be nice if there was a way to change the default value of
>a hash? So instead of undef you'll get whatever default you like?
Sure, I don't see why not. The hash access function is responsible for
returning a value, so there's no
I think this is one of many steps in the right direction. Actually, I have a
class item defined in my fork as:
class foo
reserve bar scalar;
member bar {
default(bar) = '1';
set(bar) = {some code};
get(bar) = {some code};
ensure(bar) = {some code};
confirm(bar) = {some co