this post was submitted on 24 Mar 2024
787 points (98.6% liked)

Programmer Humor

19557 readers
720 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 57 points 7 months ago* (last edited 7 months ago) (40 children)

Is it wrong that I'm stuck trying to figure out what language this is?

Trying to figure out what string.length and print(var) exist in a single language.... Not Java, not C# (I'm pretty sure its .Length, not length), certainly not C, C++ or Python, Pascal, Schme or Haskell or Javascript or PHP.

[–] [email protected] 10 points 7 months ago (1 children)

This is quite a cheap answer but maybe it's just pseudo code. We had exercises in university about pseudo code with examples that intentionally broke all syntax systems and conventions to show that not everything has to be executable that you write down in a theoretical computer science homework

[–] [email protected] -3 points 7 months ago (1 children)

It's a shitty question. It's implied by the fact that "24" is wrong that the answer is "6", the length of the string "Monday".

In some languages dot access on objects could give you the properties of the object type (things pertaining to a "day" object) but this would still be ambiguous since a day's length can be measured in many different ways.

In others, it would require you to call length as a function (.length()) or not be available at all, or require you to pass the object into another function [ length_in_seconds(day_x)]

[–] [email protected] 11 points 7 months ago

I think the question is fine, but we have to assume they covered this type of method prior to the exam, where .length would result in the character count of a String.

load more comments (38 replies)