Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. String foo() {
  2. // will be automatically converted to a String on account of the return type
  3. new StringBuilder('foo')
  4. }
  5.  
  6. assert foo() == 'foo'
  7.  
  8. Set<Integer> foo() {
  9. // will be automatically converted to a Set on account of the return type
  10. [1, 2, 2]
  11. }
  12.  
  13. assert foo().size() == 2
  14.  
  15. Integer foo(Object[] a) {
  16. a.length
  17. }
  18.  
  19. List myList = [1, 2, 3]
  20. assert 3 == foo(myList)
  21.  
  22. Integer foo(Object[] a) {
  23. a.length
  24. }
  25.  
  26. List myList = [1, 2, 3]
  27. assert 3 == foo(myList.toArray())
  28.  
  29. Integer foo(Integer[] l) {
  30. l.size()
  31. }
  32.  
  33. assert 3 == foo([1, 2, 3])
  34.  
  35. Integer foo(Object[] l) {
  36. l.size()
  37. }
  38.  
  39. def list = [1, 2, 3]
  40. assert 3 == foo(*list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement