summaryrefslogtreecommitdiffhomepage
path: root/pt-br
diff options
context:
space:
mode:
authorMarcel Ribeiro Dantas, Ph.D <ribeirodantasdm@gmail.com>2022-07-07 14:57:28 +0200
committerGitHub <noreply@github.com>2022-07-07 14:57:28 +0200
commit2815ed779524663db5b1278898ca907dbe1f722c (patch)
tree0d539b91c7eb8a6070ab274190e54cd285aad73f /pt-br
parent4bbbdf09a04c5d54590ba067fa6dc11eeefbdc2e (diff)
parent28ea2a46224aec4b2ed5366b5d4139dbdb101487 (diff)
Merge pull request #4428 from adambard/mribeirodantas-update-groovy-pt
Update groovy-pt.html.markdown
Diffstat (limited to 'pt-br')
-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)