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

Re : I need Help

$
0
0
OK, let me illustrate it:
  1. void setup()
  2. {
  3.   println(getItems()[2]);
  4.   exit();
  5. }
  6.  
  7. int[] getItems()
  8. {
  9.   int[] items = { 0, 1, 2, 3, 4, 5 };
  10.   return items;
  11. }
getItems() returns an array, and we can pick one item from it directly.
The return value of a method can be used immediately.
This allows some nice tricks, like chaining calls:
  1. StringBuilder sb = new StringBuilder("Initial ");
  2. sb.append("one ").append("two ").append("Last");
because append() just returns this.

Viewing all articles
Browse latest Browse all 1768

Trending Articles