|
ru.perl- RU.PERL ---------------------------------------------------------------------- From : Nick Kostirya 2:5020/400 11 Feb 2004 11:01:54 To : Yury Kopyl Subject : Re: C-style Logical Defined-Or -------------------------------------------------------------------------------- > > NK>>> Привет. > NK>>> А что "C-style Logical Defined-Or" убрали? > > NK>>> В http://search.cpan.org/~nwclark/perl-5.8.3/pod/perlop.pod не > NK>>> могу найти. > > > NK> http://search.cpan.org/~nwclark/perl-5.8.3/pod/perlop.pod#C-style_ > NK> Logical_Or > > NK> Что то не вижу там оператора // > > http://search.cpan.org/~nwclark/perl-5.8.3/pod/perlop.pod#Assignment_Operato > rs Hашел! Это в http://search.cpan.org/src/HVDS/perl-5.9.0/pod/perlop.pod Вот цитата =head2 C-style Logical Defined-Or Although it has no direct equivalent in C, Perl's C<//> operator is related to its C-style or. In fact, it's exactly the same as C<||>, except that it tests the left hand side's definedness instead of its truth. Thus, C<$a // $b> is similar to C<defined($a) || $b> (except that it returns the value of C<$a> rather than the value of C<defined($a)>) and is exactly equivalent to C<defined($a) ? $a : $b>. This is very useful for providing default values for variables. If you actually want to test if at least one of C<$a> and C<$b> is defined, use C<defined($a // $b)>. --- ifmail v.2.15dev5.3 * Origin: Demos online service (2:5020/400) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.perl/6577bfe4b6f4.html, оценка из 5, голосов 10
|