Thread: {} vs ||
View Single Post
  #2  
Old 06-10-2007, 03:28 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I think extent = {300,250}; and extent = "300 250"; was just to allow compatibility between both torque and GS2. Or maybe GS2 and GS1... Not sure which case but I do believe it's for compatibility.

I use extent = {300,250}; but I'm not sure if this is the best way.

As for checks,
PHP Code:
function onCreated()
{
  
this.test 10
  if (
this.test in |5,50|)
  {
    echo(
"Test 1 true");
  }
  if (
this.test in {5,50})
  {
    echo(
"Test 2 true");
  }

Test 1 is true while test 2 isn't. Basically, | | tests for all numbers in between. So for |5,50| it checks if the number is in between 5 and 50. Using {5,50} however only checks if the number is part of the array: it doesn't check in between numbers. So unless the result is 5 or 50, it's false.

Array checking does have one advantage though, it can check for multiple values while not needing to check all in between values. For example, if I did
PHP Code:
function onCreated()
{
  
this.test 10;
  if (
this.test in {5,50,10})
  {
    echo(
"Test 2 true");
  }

This would echo true as this.test is contained within the array. This method can also work like this:
PHP Code:
function onCreated()
{
  
this.food "pizza";
  if (
this.food in {"pizza","pie","banana"})
  {
    
printf("I like %s",this.food);
  }

This method would print "I like pizza" since pizza was in the array. Hope this helps .
Reply With Quote