4 May 2010 at 18:37 #1 RobMunfy RobMunfy Associate Joined 18 Mar 2007 Posts 291 Could anybody possibly explain what this is doing: Code: val ? 255. / val : 0. Thanks edit - it's passed as an argument to a function where val is a float
Could anybody possibly explain what this is doing: Code: val ? 255. / val : 0. Thanks edit - it's passed as an argument to a function where val is a float
4 May 2010 at 18:52 #2 zpos zpos Associate Joined 11 Jan 2004 Posts 1,445 Take a peek at this http://en.wikipedia.org/wiki/Conditional_operator It is essentially shorthand for an if else statement. if (val) { 255. / val } else { 0. } As it's being passed in as an argument to a function, a number is derived and passed. The decimal point after the numbers is forcing a type.
Take a peek at this http://en.wikipedia.org/wiki/Conditional_operator It is essentially shorthand for an if else statement. if (val) { 255. / val } else { 0. } As it's being passed in as an argument to a function, a number is derived and passed. The decimal point after the numbers is forcing a type.
4 May 2010 at 19:01 #3 RobMunfy RobMunfy Associate OP Joined 18 Mar 2007 Posts 291 ah right, so essentially it's saying: if(val) send 255/val to function else send 0 to function ?
4 May 2010 at 20:08 #4 RobMunfy RobMunfy Associate OP Joined 18 Mar 2007 Posts 291 wow, sorry just realised i posted this in the wrong section! Sorted it now anyway. Thanks
4 May 2010 at 22:19 #5 Spyhop Spyhop Soldato Joined 16 May 2005 Posts 6,509 Location Cold waters So it avoids a divide by zero!