LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm not really understanding this term from C# for the operator ?? but the Wikipedia page doesn't make sense when identifying JS's || with Perl's "defined-or" // operator.

see http://en.wikipedia.org/wiki/Talk:Null_coalescing_operator#Either_wrong_for_Perl_or_for_Javascript.2C_Ruby_and_Python

Could someone with deeper knowledge in C# help me understand?

Cheers Rolf

Replies are listed 'Best First'.
Re: Is // a "Null coalescing operator" ?
by Anonymous Monk on Aug 09, 2010 at 01:25 UTC
    Your question makes no sense, what is it you don't understand? ?? is the defined-or operator, except that C# has extra caveats ... ?? Operator (C# Reference)
      I already read the definition but I wasn't sure what a "nullable type"¹) was supposed to mean.

      So you say "null" in C# corresponds to "undef" in Perl?

      (e.g. JS has both, "undefined" and "null", which are different)

      Then consequently these attempts to list the or-operators from JS, Ruby and Python as examples are wrong(?)

      Cheers Rolf

      1) I imagine a non-nullable type is a type which doesn't allow uninitializing declarations, or in perl-lingo  my $typevar wouldn't be allowed but  my $typevar=init() would.

        I already read the definition but I wasn't sure what a "nullable type"¹) was supposed to mean.

        So you ask "what does nullable type mean?" see? :)

        So you say "null" in C# corresponds to "undef" in Perl?

        Yes, in the case of defined-or operator, in perl it really means not-undef-or and in C# it means not-null-or

        See the caveats Nullable Types (C#)

        Then consequently these attempts to list the or-operators from JS, Ruby and Python as examples are wrong(?)

        I don't see how