#] WTF is wrong with code?
No, I'm serious. Some shit really does not make sense.
Note: I was inspired to make this page by this page.
Note: These code blocks are typed by hand. The interpreter on your machine will most likely look different than what is shown. Additionally, terminal based interpreters do not have syntax highlighting. I added that here so people who don't code have an idea of what is what kinda.
#] JavaScript
Let's talk about JavaScript.
Some background is necessary.
#] Equals
So, lets talk about this:
>>> 1 == "1"
true
>>> 1 === "1"
false
>>> 1 ==== "1"
SyntaxError
Strings are not integers, and should not be treated as such. This is silly.
#] Lists
In all languages, you can make two lists by appending the contents of one list to another using the
>>> [1, 2, 3] + [4, 5, 6]
[1, 2, 3, 4, 5, 6]
>>> [] + []
[]
>>> [] + []
""
>>> [] - []
0
#] Objects
This should be quite simple. Let's see what happens when we add an object and a list together. They are completely incompatible data types, so it should throw a TypeError or something like that.
>>> [] + {}
"[object Object]"
>>> {} + []
0
>>> {} - []
-0
>>> {} + {}
NaN
#] Strings
A string is text. Like "hi". Most languages do not automatically convert datatypes without explicit instruction. JavaScript is one of those exceptions. So, adding will concatonate, or append to the end of the string.
>>> 12 + "34"
"1234"
>>> 12 - "34"
-22
#] Python
Python is a very sane language, relatively speaking to JavaScript of course. Python accepts inputs directly from the console. Let's input a number.
>>> int(input("Input a number ] ")) # Convert to an integer [no decimals]
Input a number ] 2.5
ValueError
#] Ruby
Let's talk about Ruby.
#] Assigning variables
If a variable is not defined, it should throw an error.
>>> a
NameError
>>> b
NameError
>>> a = b
NameError
>>> a = a
nil
#] Funky types.
>>> nil
nil
>>> nil?
false
BY PRIZ WITH WINKY BRACKET FACE ;]
Home page // View source
© PRIZ ;], 2022
*loading funny text thing