Advertisement
fatimacasau

GString

Jul 25th, 2012
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.59 KB | None | 0 0
  1. // Múltiples líneas con salto de línea
  2. assert '''hello,
  3. world''' == 'hello,\nworld'
  4.  
  5. // Múltiples líneas sin salto de línea
  6. assert 'hello, \
  7. world' == 'hello, world'
  8.  
  9. // También con triples dobles comillas
  10. def text = """\
  11. Good morning. \
  12. Good night again."""
  13.  
  14. assert text == "Good morning. Good night again."
  15.  
  16. // Sustitución de variables con dobles comillas
  17.  
  18. def name = 'Groovy'
  19. assert "hello $name, how are you today?" == "hello Groovy, how are you today?"
  20.  
  21. def a = 'How are you?'
  22. assert "The phrase '$a' has length ${a.size()}" ==
  23.     "The phrase 'How are you?' has length 12"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement