Programming/Polyglot Problems: Difference between revisions

From etwiki
Jump to navigation Jump to search
(Created page with "''Have you ever gotten syntax errors because you know how to do the thing in one language but can't remember how to do that the other one?'' {| !Java !C# !Python !Ruby |- |...")
 
(Fix syntax highlighting yay)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
''Have you ever gotten syntax errors because you know how to do the thing in one language but can't remember how to do that the other one?''
''Have you ever gotten syntax errors because you know how to do the thing in one language but can't remember how to do that the other one?''


{|
==If-Statements==
!Java
!C#
!Python
!Ruby
|-
|


|
Python
|
<syntaxhighlight lang='python' line>
|
if condition:
 
  do_thing
|}
elif other_condition:
 
  do_other_thing
<syntaxhighlight lang="python" line='line'>
else:
def quick_sort(arr):
  do_else_thing
less = []
pivot_list = []
more = []
if len(arr) <= 1:
return arr
else:
pass
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="ruby" line='line'>
Ruby
<syntaxhighlight lang='ruby' line>
if condition
if condition
   do_thing
   do_thing
elsif
elsif other_condition
   do_other_thing
   do_other_thing
else
else

Latest revision as of 12:16, 1 April 2024

Have you ever gotten syntax errors because you know how to do the thing in one language but can't remember how to do that the other one?

If-Statements

Python

if condition:
  do_thing
elif other_condition:
  do_other_thing
else:
  do_else_thing

Ruby

if condition
  do_thing
elsif other_condition
  do_other_thing
else
  do_else_thing
end