1 class SpaceShip {} 2 class GiantSpaceShip extends SpaceShip {} 3 4 class Asteroid { 5 6 public void collideWith(SpaceShip sp) { 7 System.out.println("Asteroid hit a SpaceShip"); 8 } 9 public void collideWith(GiantSpaceShip gsp) { 10 System.out.println("Asteroid hit a GiantSpaceShip"); 11 } 12 } 13 14 class ExplodingAsteroid extends Asteroid { 15 16 public void collideWith(SpaceShip sp) { 17 System.out.println("ExplodingAsteroid hit a SpaceShip"); 18 } 19 public void collideWith(GiantSpaceShip gsp) { 20 System.out.println("ExplodingAsteroid hit a GiantSpaceShip"); 21 } 22 } 23 24 public class DoubleDispatchTest { 25 public static void main(String args[]) { 26 Asteroid ast = new Asteroid(); 27 Asteroid ast1 = new ExplodingAsteroid(); 28 SpaceShip sp = new SpaceShip(); 29 SpaceShip sp1 = new GiantSpaceShip(); 30 ast.collideWith(sp); 31 ast.collideWith(sp1); 32 ast1.collideWith(sp); 33 ast1.collideWith(sp1); 34 } 35 }
eachline
de un objeto File
? ¿Que argumentos recibe?
getText
de un objeto File
?
groovy:000> line = "hello world" ===> hello world groovy:000> m = line =~ '[aeiou]' ===> java.util.regex.Matcher[pattern=[aeiou] region=0,11 lastmatch=]¿Que retorna
m[0]
? ¿y m[1]
?
¿y m[2]
?
line =~ '[aeiou]'
en un contexto booleano?
find
de la clase String
?
¿Que argumentos recibe?
line.find(/(?ix) href \s* = \s* "( [^"]* )"/) { ... }
(?ix)
?
\s
?
[^"]
?
find
?
Casiano Rodríguez León