Im trying to grasp arrays and I’m having trouble with this concept. I have looked in books and read tutroials online but I cant understand why this wont work. I was wondering why this code works…
`using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
int[] myArray = new int[3];
myArray [0] = 22;
Debug.Log (myArray [0]);
}
// Update is called once per frame
void Update () {
}
}
`
but if I write it where I want to name the array like this, it wont work I get an error
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
weapon[] weapons = new weapons[3];
int[] newArray = new int[4];
weapons [0] = 22;
Debug.Log (weapons [0]);
}
// Update is called once per frame
void Update () {
}
}