Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : I need Help

$
0
0

It is not a way to return a single element by a special magic!
I guess there's some sorta miscommunication!
The way I understood is that this exotic syntax filters out a specific element from a returned array.
Now you just say that it's not a way to return a single element?  

I did an example below, and it doesn't compile b/c
it cannot convert an int (a single element) into an int[] (a whole array)!

And your 2nd example doesn't filter out anything. So, nothing exotic there! 
    void setup() {
      int[] a;
    
      // regular expected access:
      a = getArray();
      println(a);
    
      // cannot convert int to int[]:
      a = getArray()[1];  
      println(a[1]);
    
      exit();
    }
    
    int[] getArray() {
      return new int[] {-2, 34, 5};
    }
    


Viewing all articles
Browse latest Browse all 1768

Trending Articles