r/ProgrammerHumor • • Aug 01 '22

>>>print(“Hello, World!”)

Post image
60.8k Upvotes

5.7k comments sorted by

View all comments

0

u/[deleted] Aug 01 '22

[deleted]

42

u/a-slice-of-toast Aug 01 '22

tells my printer to print

11

u/WraithWinterly Aug 01 '22

Sometimes I write print() in JavaScript instead of console.log and the print dialog appears

2

u/BlendeLabor Aug 01 '22

Oh fuck I need to bring this up to my dev "coworkers"

1

u/CarterRussellYT Aug 01 '22

would this print false? I’m kinda new to programming and I also have no idea what lang this is

2

u/soffey Aug 01 '22

Depends on the language. In something with strict typing it would print false, because it's comparing a number (likely interpreted as an integer) to a string or a char (again varies with language).

There are some languages that don't do strict typing, like JavaScript and Python, but I honestly don't remember if this is one of the weird things that would return true or not.

2

u/CarterRussellYT Aug 01 '22

okay that’s what I figured, because 1 != “1”. I’ve been mostly working with c# but when I did use JavaScript i think this would have returned true

edit: just tested it in code.org, it prints true

0

u/[deleted] Aug 02 '22

[deleted]

2

u/CarterRussellYT Aug 02 '22

what does the === mean? I know = is for assignments and == is for conditionals, but what is === for?

2

u/Real_Robo_Knight Aug 02 '22

In Js, == is a week comparison. If both values are not the same type, it tries to convert one to the other, and then check. === Is strong comparison, where if they are difrent types, the expression returns false