вторник, 6 августа 2013 г.

Partial interface implementation in groovy

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
interface X {
  void a()
  void b()  
}

class XAdapter implements X {
  void a() { println 'default implementation of a' }
  void b() { println 'default implementation of b' }
}

def o = [ 
  a: { println 'overridden implementation of a' } 
] as XAdapter

o.a()
o.b()
will output:
overridden implementation of a
default implementation of b

Комментариев нет:

Отправить комментарий