Operator Precedence Rules in Ruby

Beschreibung

Think you know operator precedence rules? Test yourself on operator precedence rules in ruby with this short quiz.
Domhnall Murphy
Quiz von Domhnall Murphy, aktualisiert more than 1 year ago
Domhnall Murphy
Erstellt von Domhnall Murphy vor mehr als 3 Jahre
2473
0

Zusammenfassung der Ressource

Frage 1

Frage
What is the output from the following ruby statement: puts (1 + 2 * 2)
Antworten
  • 5
  • 6
  • 3
  • 4

Frage 2

Frage
What is the output from the following ruby statement: puts (4 * 6 / 2 * 2)
Antworten
  • 6
  • 24
  • 3
  • 0

Frage 3

Frage
What is the output from the following ruby expression: puts (4 / 2 * 2 + 2 / 2)
Antworten
  • 4
  • 2
  • 3
  • 5

Frage 4

Frage
What is the output from the following ruby statement: puts (5 + 10 % 3 + 6 / 2)
Antworten
  • 9
  • 3
  • \(5 \frac{1}{2} \)
  • \(6 \frac{1}{2} \)

Frage 5

Frage
What is the output from the following ruby statement: puts (4 * 2 ** 2 * 2)
Antworten
  • 32
  • 16
  • 128
  • 64

Frage 6

Frage
What is the output from the final ruby statement: c = 3 d = 4 puts (c or d == 7)
Antworten
  • 3
  • true
  • false
  • 1

Frage 7

Frage
What is the output of the last ruby statement x = 5 && 4 puts x
Antworten
  • true
  • false
  • 5
  • 4

Frage 8

Frage
What is the output of the last ruby statement x = 5 and 4 puts x
Antworten
  • true
  • false
  • 5
  • 4

Frage 9

Frage
What is the output from the final ruby statement: a = false b = true ! a || b = false puts b
Antworten
  • true
  • false
  • 0
  • 1

Frage 10

Frage
What is the output from the following ruby statement puts (13 & 10 << 1)
Antworten
  • 4
  • 16
  • 5
  • 8

Frage 11

Frage
What is the output from the final ruby statement a = false b = true puts (a && b ? 'foo' : 'bar')
Antworten
  • true
  • false
  • foo
  • bar

Frage 12

Frage
What is the output from the final ruby statement a = false b = true puts (a and b ? 'foo' : 'bar')
Antworten
  • true
  • false
  • foo
  • bar
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Ruby+Rails - Borrador
Carlos Ortiz Gutierrez
Operadores logicos en ruby on rails
Pablo Soto
Objetos mutables e inmutables
Benjamin Villalpando
Tools and resources for computational thinking
Miguel Salamanca
What is programming language? Why python?
51143
Eloquent JavaScript
Marco s
Maleta Didáctica "Ipiales te llevo en mi corazón"
alejalove1708
HIPERTEXTO
RUBY PEÑALOZA
Condiciones Ruby on rails
Pablo Soto
RUBY
nangas_94
Parámetros Curriculares para la educación indígena
kawaii-sweet