Search Unity

arr.push arr. add

Discussion in 'Scripting' started by yellowlabrador, Aug 31, 2007.

  1. yellowlabrador

    yellowlabrador

    Joined:
    Oct 20, 2005
    Posts:
    562
  2. bronxbomber92

    bronxbomber92

    Joined:
    Nov 11, 2006
    Posts:
    888
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not quite; you can do this with Push:

    Code (csharp):
    1. var myArray = new Array ("a", "b", "c", "d");
    2. if (myArray.Push("e") > 4) {
    3.      print ("Hey, stop putting so much stuff in the array!");
    4. }
    But you can't do that with Add, since Add doesn't return anything but Push returns the length of the array.

    --Eric