this post was submitted on 24 Mar 2024
787 points (98.6% liked)
Programmer Humor
19623 readers
1 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
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
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.
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
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)]
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.