summaryrefslogtreecommitdiffhomepage
path: root/pt-br/groovy-pt.html.markdown
diff options
context:
space:
mode:
authorBoris Verkhovskiy <boris.verk@gmail.com>2024-04-03 04:31:13 -0700
committerGitHub <noreply@github.com>2024-04-03 04:31:13 -0700
commitfbf132752b743d0f43c3395da0699bee53da22df (patch)
tree56da43c86e1aebd24e3913b405e21d6f2812e9a3 /pt-br/groovy-pt.html.markdown
parent247dc6e86c1421fa031e4b61c42c05ca6e09bfb0 (diff)
parentc166f2acb295627c5ae305a6dd517a27ca8fece6 (diff)
Merge branch 'master' into patch-1
Diffstat (limited to 'pt-br/groovy-pt.html.markdown')
-rw-r--r--pt-br/groovy-pt.html.markdown15
1 files changed, 12 insertions, 3 deletions
diff --git a/pt-br/groovy-pt.html.markdown b/pt-br/groovy-pt.html.markdown
index 3acfce21..dff3f2e1 100644
--- a/pt-br/groovy-pt.html.markdown
+++ b/pt-br/groovy-pt.html.markdown
@@ -5,7 +5,8 @@ filename: learngroovy-pt.groovy
contributors:
- ["Roberto Pérez Alcolea", "http://github.com/rpalcolea"]
translators:
- - ["João Farias", "https://github.com/JoaoGFarias"]
+ - ["João Farias", "https://github.com/joaogfarias"]
+ - ["Marcel Ribeiro-Dantas", "https://github.com/mribeirodantas"]
lang: pt-br
---
@@ -201,8 +202,16 @@ if(x==1) {
//Groovy também suporta o operador ternário
def y = 10
-def x = (y > 1) ? "functionou" : "falhou"
-assert x == "functionou"
+def x = (y > 1) ? "funcionou" : "falhou"
+assert x == "funcionou"
+
+//E suporta o 'The Elvis Operator' também!
+//Em vez de usar o operador ternário:
+
+displayName = nome.name ? nome.name : 'Anonimo'
+
+//Podemos escrever:
+displayName = nome.name ?: 'Anonimo'
//Loop 'for'
//Itera sobre um intervalo (range)