1,What is wrong with the following conditional statement?
puts “Welcome to CIS199!” if x==1
|
Missing an “end” keyword in the “if” statement. |
|
The conditional expression x==1 is not surrounded by the
parenthesis ( ). |
|
The “if" keyword should have been replaced with the “unless"
keyword. |
|
The conditional expression x==1 should have been written as
x=1 |
2.Ruby interpreter parses code before running it, and makes
certain decisions such as allocation of local variables and their
assignment to values.
3.It is OK to use assignment in a conditional test. Assuming x =
0 already, the following two conditional expressions produce the
same outcome:
if x = 0
puts “CIS199”;
end
if x == 0
puts “CIS199”;
end
4.In a “case" statement, there can be multiple “when”
expressions but only one “when" expression will be evaluated.
5.When comparing two strings, string1 and string2, with ==, the
following statement compares both strings character by
character:
string1 == string2
6.It is syntactically correct to have a “case” statement without
a test expression such as the following
case
when x == y
puts “CIS199"
end