[Proto-Scripty] Re: ternary operators
Drop the parens around the first argument. function foo(arg) { return $(arg) ? true : alert('Element Does not exist'); // i commented this out: false; } ... On Tue, Jul 28, 2009 at 12:02 PM, Alex McAuley webmas...@thecarmarketplace.com wrote: In my usual Not enough coffee moments i just used an If/Else instead lol Not sure why i was trying to cut code using a tenary ... We live and learn Sorry for useless post Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Jeztah webmas...@thecarmarketplace.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, July 28, 2009 4:51 PM Subject: [Proto-Scripty] ternary operators Afternoon guys Is it possible in javascript to give out 2 answers to a tenary opertor (doesnt make sense i know - see below) function foo(arg) { return ($(arg)) ? true : alert('Element Does not exist');false; } ... (wrapped in window loaded function) foo('baz'); // doesnt exist so i want it to alert the alert and return false to halt the script... div id=bar/div Is this the right way to do it in the operator or cant it be done and no i dont want to make 2 functions i would like it in one if it can be done. Regards Alex Mcauley http://www.thevacancymarket.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ternary operators
Sorry you missed the point i was trying to achieve. I wanted the operator to in essence evaluate 2 responses for example. alert('Element Does not exist'); alert('The second responsee'); However it cannot be achieved so it must be done usung if/else.. Regards Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Rick Waldron To: prototype-scriptaculous@googlegroups.com Sent: Thursday, July 30, 2009 1:18 PM Subject: [Proto-Scripty] Re: ternary operators Drop the parens around the first argument. function foo(arg) { return $(arg) ? true : alert('Element Does not exist'); // i commented this out: false; } ... On Tue, Jul 28, 2009 at 12:02 PM, Alex McAuley webmas...@thecarmarketplace.com wrote: In my usual Not enough coffee moments i just used an If/Else instead lol Not sure why i was trying to cut code using a tenary ... We live and learn Sorry for useless post Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Jeztah webmas...@thecarmarketplace.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, July 28, 2009 4:51 PM Subject: [Proto-Scripty] ternary operators Afternoon guys Is it possible in javascript to give out 2 answers to a tenary opertor (doesnt make sense i know - see below) function foo(arg) { return ($(arg)) ? true : alert('Element Does not exist');false; } ... (wrapped in window loaded function) foo('baz'); // doesnt exist so i want it to alert the alert and return false to halt the script... div id=bar/div Is this the right way to do it in the operator or cant it be done and no i dont want to make 2 functions i would like it in one if it can be done. Regards Alex Mcauley http://www.thevacancymarket.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ternary operators
Huh? Jeztah == Alex? On Thu, Jul 30, 2009 at 8:37 AM, Alex McAuley webmas...@thecarmarketplace.com wrote: Sorry you missed the point i was trying to achieve. I wanted the operator to in essence evaluate 2 responses for example. alert('Element Does not exist'); alert('The second responsee'); However it cannot be achieved so it must be done usung if/else.. Regards Alex Mcauley http://www.thevacancymarket.com - Original Message - *From:* Rick Waldron waldron.r...@gmail.com *To:* prototype-scriptaculous@googlegroups.com *Sent:* Thursday, July 30, 2009 1:18 PM *Subject:* [Proto-Scripty] Re: ternary operators Drop the parens around the first argument. function foo(arg) { return $(arg) ? true : alert('Element Does not exist'); // i commented this out: false; } ... On Tue, Jul 28, 2009 at 12:02 PM, Alex McAuley webmas...@thecarmarketplace.com wrote: In my usual Not enough coffee moments i just used an If/Else instead lol Not sure why i was trying to cut code using a tenary ... We live and learn Sorry for useless post Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Jeztah webmas...@thecarmarketplace.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, July 28, 2009 4:51 PM Subject: [Proto-Scripty] ternary operators Afternoon guys Is it possible in javascript to give out 2 answers to a tenary opertor (doesnt make sense i know - see below) function foo(arg) { return ($(arg)) ? true : alert('Element Does not exist');false; } ... (wrapped in window loaded function) foo('baz'); // doesnt exist so i want it to alert the alert and return false to halt the script... div id=bar/div Is this the right way to do it in the operator or cant it be done and no i dont want to make 2 functions i would like it in one if it can be done. Regards Alex Mcauley http://www.thevacancymarket.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ternary operators
the original post is signed with my name !! Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Rick Waldron To: prototype-scriptaculous@googlegroups.com Sent: Thursday, July 30, 2009 7:31 PM Subject: [Proto-Scripty] Re: ternary operators Huh? Jeztah == Alex? On Thu, Jul 30, 2009 at 8:37 AM, Alex McAuley webmas...@thecarmarketplace.com wrote: Sorry you missed the point i was trying to achieve. I wanted the operator to in essence evaluate 2 responses for example. alert('Element Does not exist'); alert('The second responsee'); However it cannot be achieved so it must be done usung if/else.. Regards Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Rick Waldron To: prototype-scriptaculous@googlegroups.com Sent: Thursday, July 30, 2009 1:18 PM Subject: [Proto-Scripty] Re: ternary operators Drop the parens around the first argument. function foo(arg) { return $(arg) ? true : alert('Element Does not exist'); // i commented this out: false; } ... On Tue, Jul 28, 2009 at 12:02 PM, Alex McAuley webmas...@thecarmarketplace.com wrote: In my usual Not enough coffee moments i just used an If/Else instead lol Not sure why i was trying to cut code using a tenary ... We live and learn Sorry for useless post Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Jeztah webmas...@thecarmarketplace.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, July 28, 2009 4:51 PM Subject: [Proto-Scripty] ternary operators Afternoon guys Is it possible in javascript to give out 2 answers to a tenary opertor (doesnt make sense i know - see below) function foo(arg) { return ($(arg)) ? true : alert('Element Does not exist');false; } ... (wrapped in window loaded function) foo('baz'); // doesnt exist so i want it to alert the alert and return false to halt the script... div id=bar/div Is this the right way to do it in the operator or cant it be done and no i dont want to make 2 functions i would like it in one if it can be done. Regards Alex Mcauley http://www.thevacancymarket.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ternary operators
Hehe. I guess i missed that. I read through these pretty quickly... On Thu, Jul 30, 2009 at 2:35 PM, Alex McAuley webmas...@thecarmarketplace.com wrote: the original post is signed with my name !! Alex Mcauley http://www.thevacancymarket.com - Original Message - *From:* Rick Waldron waldron.r...@gmail.com *To:* prototype-scriptaculous@googlegroups.com *Sent:* Thursday, July 30, 2009 7:31 PM *Subject:* [Proto-Scripty] Re: ternary operators Huh? Jeztah == Alex? On Thu, Jul 30, 2009 at 8:37 AM, Alex McAuley webmas...@thecarmarketplace.com wrote: Sorry you missed the point i was trying to achieve. I wanted the operator to in essence evaluate 2 responses for example. alert('Element Does not exist'); alert('The second responsee'); However it cannot be achieved so it must be done usung if/else.. Regards Alex Mcauley http://www.thevacancymarket.com - Original Message - *From:* Rick Waldron waldron.r...@gmail.com *To:* prototype-scriptaculous@googlegroups.com *Sent:* Thursday, July 30, 2009 1:18 PM *Subject:* [Proto-Scripty] Re: ternary operators Drop the parens around the first argument. function foo(arg) { return $(arg) ? true : alert('Element Does not exist'); // i commented this out: false; } ... On Tue, Jul 28, 2009 at 12:02 PM, Alex McAuley webmas...@thecarmarketplace.com wrote: In my usual Not enough coffee moments i just used an If/Else instead lol Not sure why i was trying to cut code using a tenary ... We live and learn Sorry for useless post Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Jeztah webmas...@thecarmarketplace.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, July 28, 2009 4:51 PM Subject: [Proto-Scripty] ternary operators Afternoon guys Is it possible in javascript to give out 2 answers to a tenary opertor (doesnt make sense i know - see below) function foo(arg) { return ($(arg)) ? true : alert('Element Does not exist');false; } ... (wrapped in window loaded function) foo('baz'); // doesnt exist so i want it to alert the alert and return false to halt the script... div id=bar/div Is this the right way to do it in the operator or cant it be done and no i dont want to make 2 functions i would like it in one if it can be done. Regards Alex Mcauley http://www.thevacancymarket.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ternary operators
Me too !!! Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Rick Waldron To: prototype-scriptaculous@googlegroups.com Sent: Thursday, July 30, 2009 7:39 PM Subject: [Proto-Scripty] Re: ternary operators Hehe. I guess i missed that. I read through these pretty quickly... On Thu, Jul 30, 2009 at 2:35 PM, Alex McAuley webmas...@thecarmarketplace.com wrote: the original post is signed with my name !! Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Rick Waldron To: prototype-scriptaculous@googlegroups.com Sent: Thursday, July 30, 2009 7:31 PM Subject: [Proto-Scripty] Re: ternary operators Huh? Jeztah == Alex? On Thu, Jul 30, 2009 at 8:37 AM, Alex McAuley webmas...@thecarmarketplace.com wrote: Sorry you missed the point i was trying to achieve. I wanted the operator to in essence evaluate 2 responses for example. alert('Element Does not exist'); alert('The second responsee'); However it cannot be achieved so it must be done usung if/else.. Regards Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Rick Waldron To: prototype-scriptaculous@googlegroups.com Sent: Thursday, July 30, 2009 1:18 PM Subject: [Proto-Scripty] Re: ternary operators Drop the parens around the first argument. function foo(arg) { return $(arg) ? true : alert('Element Does not exist'); // i commented this out: false; } ... On Tue, Jul 28, 2009 at 12:02 PM, Alex McAuley webmas...@thecarmarketplace.com wrote: In my usual Not enough coffee moments i just used an If/Else instead lol Not sure why i was trying to cut code using a tenary ... We live and learn Sorry for useless post Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Jeztah webmas...@thecarmarketplace.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, July 28, 2009 4:51 PM Subject: [Proto-Scripty] ternary operators Afternoon guys Is it possible in javascript to give out 2 answers to a tenary opertor (doesnt make sense i know - see below) function foo(arg) { return ($(arg)) ? true : alert('Element Does not exist');false; } ... (wrapped in window loaded function) foo('baz'); // doesnt exist so i want it to alert the alert and return false to halt the script... div id=bar/div Is this the right way to do it in the operator or cant it be done and no i dont want to make 2 functions i would like it in one if it can be done. Regards Alex Mcauley http://www.thevacancymarket.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ternary operators
Hi Alex, However it cannot be achieved so it must be done usung if/else.. Well, this is JavaScript, there's almost always a way. I can think of four off the top of my head that keep it in a single expression -- but all of them are much worse (most of them much, much, much worse) than using an if/else. ;-) The four are: 1. Massage the return value of the first thing you want to do to force it to be the return value you want. Actually, in your specific case, you don't have to anything: return $(arg) ? true : alert('Element Does not exist'); alert has no return value, hence your function returns either true or undefined, which is good enough for anything branching on its return value (undefined is falsey, after all). If you really want a false, use !! to force it. Blech. 2. If you wanted to return something other than false, and if the first part has an invariant result, you could manipulate that return value to be falsey and use the OR operator, which is much more powerful in JavaScript than in most languages (more here[1]): return $(arg) ? It's there : (alert('Element Does not exist') || It's not there); or, demonstrating manipulation: return $(arg) ? It's there : (!setTimeout(...) || It's not there); ...since setTimeout returns a non-zero number; !setTimeout is false and so the return value (for that second operand) is It's not there. Blech blech. 3. Wrap the two-part bit in an on-the-fly function: return $(arg) ? true : (function(){ alert('Element Does not exist'); return false;})()); Blech blech cough. 4. Use eval (!): return $(arg) ? true : eval(alert('Element Does not exist'); return false;); Blech blech cough retch. I bet there are others. So: *Possible*, but if/else is just a way better way to go. ;-) [1] http://blog.niftysnippets.org/2008/02/javascripts-curiously-powerful-or.html -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jul 30, 1:37 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Sorry you missed the point i was trying to achieve. I wanted the operator to in essence evaluate 2 responses for example. alert('Element Does not exist'); alert('The second responsee'); However it cannot be achieved so it must be done usung if/else.. Regards Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: Rick Waldron To: prototype-scriptaculous@googlegroups.com Sent: Thursday, July 30, 2009 1:18 PM Subject: [Proto-Scripty] Re: ternary operators Drop the parens around the first argument. function foo(arg) { return $(arg) ? true : alert('Element Does not exist'); // i commented this out: false; } ... On Tue, Jul 28, 2009 at 12:02 PM, Alex McAuley webmas...@thecarmarketplace.com wrote: In my usual Not enough coffee moments i just used an If/Else instead lol Not sure why i was trying to cut code using a tenary ... We live and learn Sorry for useless post Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Jeztah webmas...@thecarmarketplace.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, July 28, 2009 4:51 PM Subject: [Proto-Scripty] ternary operators Afternoon guys Is it possible in javascript to give out 2 answers to a tenary opertor (doesnt make sense i know - see below) function foo(arg) { return ($(arg)) ? true : alert('Element Does not exist');false; } ... (wrapped in window loaded function) foo('baz'); // doesnt exist so i want it to alert the alert and return false to halt the script... div id=bar/div Is this the right way to do it in the operator or cant it be done and no i dont want to make 2 functions i would like it in one if it can be done. Regards Alex Mcauley http://www.thevacancymarket.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ternary operators
thanks TJ, The alert() was just an example - perhaps a bad one! ... i did not however consider the || version. Regards Alex Mcauley http://www.thevacancymarket.com - Original Message - From: T.J. Crowder t...@crowdersoftware.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Thursday, July 30, 2009 8:26 PM Subject: [Proto-Scripty] Re: ternary operators Hi Alex, However it cannot be achieved so it must be done usung if/else.. Well, this is JavaScript, there's almost always a way. I can think of four off the top of my head that keep it in a single expression -- but all of them are much worse (most of them much, much, much worse) than using an if/else. ;-) The four are: 1. Massage the return value of the first thing you want to do to force it to be the return value you want. Actually, in your specific case, you don't have to anything: return $(arg) ? true : alert('Element Does not exist'); alert has no return value, hence your function returns either true or undefined, which is good enough for anything branching on its return value (undefined is falsey, after all). If you really want a false, use !! to force it. Blech. 2. If you wanted to return something other than false, and if the first part has an invariant result, you could manipulate that return value to be falsey and use the OR operator, which is much more powerful in JavaScript than in most languages (more here[1]): return $(arg) ? It's there : (alert('Element Does not exist') || It's not there); or, demonstrating manipulation: return $(arg) ? It's there : (!setTimeout(...) || It's not there); ...since setTimeout returns a non-zero number; !setTimeout is false and so the return value (for that second operand) is It's not there. Blech blech. 3. Wrap the two-part bit in an on-the-fly function: return $(arg) ? true : (function(){ alert('Element Does not exist'); return false;})()); Blech blech cough. 4. Use eval (!): return $(arg) ? true : eval(alert('Element Does not exist'); return false;); Blech blech cough retch. I bet there are others. So: *Possible*, but if/else is just a way better way to go. ;-) [1] http://blog.niftysnippets.org/2008/02/javascripts-curiously-powerful-or.html -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jul 30, 1:37 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Sorry you missed the point i was trying to achieve. I wanted the operator to in essence evaluate 2 responses for example. alert('Element Does not exist'); alert('The second responsee'); However it cannot be achieved so it must be done usung if/else.. Regards Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: Rick Waldron To: prototype-scriptaculous@googlegroups.com Sent: Thursday, July 30, 2009 1:18 PM Subject: [Proto-Scripty] Re: ternary operators Drop the parens around the first argument. function foo(arg) { return $(arg) ? true : alert('Element Does not exist'); // i commented this out: false; } ... On Tue, Jul 28, 2009 at 12:02 PM, Alex McAuley webmas...@thecarmarketplace.com wrote: In my usual Not enough coffee moments i just used an If/Else instead lol Not sure why i was trying to cut code using a tenary ... We live and learn Sorry for useless post Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Jeztah webmas...@thecarmarketplace.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, July 28, 2009 4:51 PM Subject: [Proto-Scripty] ternary operators Afternoon guys Is it possible in javascript to give out 2 answers to a tenary opertor (doesnt make sense i know - see below) function foo(arg) { return ($(arg)) ? true : alert('Element Does not exist');false; } ... (wrapped in window loaded function) foo('baz'); // doesnt exist so i want it to alert the alert and return false to halt the script... div id=bar/div Is this the right way to do it in the operator or cant it be done and no i dont want to make 2 functions i would like it in one if it can be done. Regards Alex Mcauley http://www.thevacancymarket.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ternary operators
Hi, I thought that too, but tried it and it didn't work, so I figured I had to be misremembering. Turns out I just messed up my test. :-) -- T.J. On Jul 31, 5:49 am, kangax kan...@gmail.com wrote: On Jul 30, 3:26 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi Alex, However it cannot be achieved so it must be done usung if/else.. Well, this is JavaScript, there's almost always a way. I can think of four off the top of my head that keep it in a single expression -- but all of them are much worse (most of them much, much, much worse) than using an if/else. ;-) The four are: 1. Massage the return value of the first thing you want to do to force it to be the return value you want. Actually, in your specific case, you don't have to anything: return $(arg) ? true : alert('Element Does not exist'); alert has no return value, hence your function returns either true or undefined, which is good enough for anything branching on its return value (undefined is falsey, after all). If you really want a false, use !! to force it. Blech. 2. If you wanted to return something other than false, and if the first part has an invariant result, you could manipulate that return value to be falsey and use the OR operator, which is much more powerful in JavaScript than in most languages (more here[1]): return $(arg) ? It's there : (alert('Element Does not exist') || It's not there); or, demonstrating manipulation: return $(arg) ? It's there : (!setTimeout(...) || It's not there); ...since setTimeout returns a non-zero number; !setTimeout is false and so the return value (for that second operand) is It's not there. Blech blech. 3. Wrap the two-part bit in an on-the-fly function: return $(arg) ? true : (function(){ alert('Element Does not exist'); return false;})()); Blech blech cough. 4. Use eval (!): return $(arg) ? true : eval(alert('Element Does not exist'); return false;); Blech blech cough retch. I bet there are others. You can use comma operator (which evaluates all of its expressions left to right and evaluates itself to the last expression): return $(arg) ? true : alert('...'), false; [...] -- kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ternary operators
In my usual Not enough coffee moments i just used an If/Else instead lol Not sure why i was trying to cut code using a tenary ... We live and learn Sorry for useless post Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Jeztah webmas...@thecarmarketplace.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, July 28, 2009 4:51 PM Subject: [Proto-Scripty] ternary operators Afternoon guys Is it possible in javascript to give out 2 answers to a tenary opertor (doesnt make sense i know - see below) function foo(arg) { return ($(arg)) ? true : alert('Element Does not exist');false; } ... (wrapped in window loaded function) foo('baz'); // doesnt exist so i want it to alert the alert and return false to halt the script... div id=bar/div Is this the right way to do it in the operator or cant it be done and no i dont want to make 2 functions i would like it in one if it can be done. Regards Alex Mcauley http://www.thevacancymarket.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---