push onto trinary conditional operator? 
Author Message
 push onto trinary conditional operator?

Camel 3.0 states you can assign to the conditional operator if both
the 2nd and 3rd args are legal lvalues and both are scalars or lists.

Thus:


0  1

So why doesn't this work:


  empty array

Thanks!
Phil R. Lawrence



Sat, 08 Nov 2003 22:53:01 GMT  
 push onto trinary conditional operator?

  PRL> So why doesn't this work:

                    ^               ^

that looks like a func, so that is all push sees. either wrap that and
the ,1 in () or put a + in front of the () to make it into an argument.



another solution is to use array refs:


that doesn't have the paren issues that your code has.

uri

--

SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html



Sat, 08 Nov 2003 23:27:09 GMT  
 push onto trinary conditional operator?


: Thus:

:

: 0  1
:
: So why doesn't this work:

:

:   empty array

I believe pre-5.6 perls understood this.  You can do the same with
the following ugly workaround:


Greg
--
Isn't it curious how ``page'' has become a colloquial term for the word
``document'' in hypertext, in a medium that does not have pages anymore?
Do we reuse words as soon as they are freed up by technology?  Do we reuse
those of whose destruction we can't bear to be reminded?  -- Jutta Degener



Sat, 08 Nov 2003 23:28:15 GMT  
 push onto trinary conditional operator?
Phil R Lawrence wrote in comp.lang.perl.misc:

Quote:
} Camel 3.0 states you can assign to the conditional operator if both
} the 2nd and 3rd args are legal lvalues and both are scalars or lists.
}
} Thus:

}

} 0  1
}
}
} So why doesn't this work:

}

}   empty array

push does not assign to its array argument. It modifies the array
contents.

An array ref does the job :


a:
b:1

a:1
b:

--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/



Sat, 08 Nov 2003 23:29:51 GMT  
 push onto trinary conditional operator?

  RG> } So why doesn't this work:

  RG> push does not assign to its array argument. It modifies the array
  RG> contents.

and ?: will return an lvalue array. his problem was wrong paren
grouping. see my other post on this.

uri

--

SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html



Sat, 08 Nov 2003 23:42:38 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Trinary operator and single quoted string problem

2. perl trinary operator oddity

3. Trinary operator vs =~ : sometimes it doesn't pay to be too cute

4. question re:pushing references to hashes onto an array

5. Pushing objects onto an array

6. Pushing onto hash of hash of array

7. pushing hash onto an array

8. Pushing onto multi-dimensioned arrays

9. Pushing onto array using reference

10. Pushing current line back onto <FILE>

11. Pushing formatted strings onto an array?

12. A question on the Conditional Operator

 

 
Powered by phpBB® Forum Software