oh I thought it's a joke that things are defined, or others are "immediate from" something else, while actually not. like how they love to teach this topic without explaining what is necessary
I don't think there is any possible value for the sign variable which would make that if statement do anything other than raise a TypeError.
Also "8:00:00" > "10:00:00"
but "08:00:00" < "10:00:00". comparing timestamps as strings is weird but actually works, as long as the hour is zero-padded :)
the problem with this code is that & (bitwise AND) has higher operator precedence than > and == do, so it is first trying to bitwise AND "10:00:00" with sign (which i'm assuming would also be a string) and that will always raise a TypeError.
to do what the author appears to have intended to do, they would either need use parenthesis around both comparisons to actually bitwise AND their results, or (better) to use the boolean AND operator (and) instead of &.
The boolean and operator is the right tool for the job, and since it is lower precedence it also wouldn't require that any parenthesis be added here.
Heh you're right, I didn't catch the bitwise and, so I thought you were making a TypeError joke about comparing strings. Fixing the and though (which I did naturally when I typed it into my interpreter to double-check), we get the issue that they are just using a string for the time rather than a time object. "Too early" is also a valid entry that gets us an available office.
28 Comments
Technoworcester@feddit.uk · 50 pts · 188d
Technoworcester@feddit.uk · 48 pts · 188d
Technoworcester@feddit.uk · 54 pts · 188d
Technoworcester@feddit.uk · 56 pts · 188d
NullPointerException@lemmy.ca · 16 pts · 188d
Fuck. I’m having nightmarish flashbacks looking at this. Hell.
otter@lemmy.dbzer0.com · 5 pts · 188d
Hmm, "atomic office" you say?
Unpigged@lemmy.dbzer0.com · 17 pts · 187d
Lemma 1 mentions "definition of phi", but the phi is never defined. Wtf.
NeatNit@discuss.tchncs.de · 9 pts · 187d
OP posted the two pages in the wrong order, so you (and I) saw page 2 before page 1.
Technoworcester@feddit.uk · 7 pts · 187d
Oops. Sorry.
WhyJiffie@sh.itjust.works · 2 pts · 185d
oh I thought it's a joke that things are defined, or others are "immediate from" something else, while actually not. like how they love to teach this topic without explaining what is necessary
panda_abyss@lemmy.ca · 11 pts · 188d
It did bother me there was no fall through.
otter@lemmy.dbzer0.com · 3 pts · 188d
follow?
panda_abyss@lemmy.ca · 8 pts · 188d
There’s no fall through case, it’s ambiguous what the room state should be
otter@lemmy.dbzer0.com · 2 pts · 188d
Oh, yes, sorry. Quick read. 🖖🏼
lefixxx@lemmy.world · 9 pts · 187d
I can see why there are more pages with reworks
TomMasz@lemmy.world · 3 pts · 188d
Thank you.
cypherpunks@lemmy.ml · 25 pts · 188d
TypeError: unsupported operand type(s) for &: 'str' and 'str'joyjoy@lemmy.zip · 8 pts · 188d
comparison chaining strikes again!
lengau@midwest.social · 3 pts · 188d
Idk it works for me.
Also
"8:00:00" > "10:00:00"cypherpunks@lemmy.ml · 6 pts · 187d
I don't think there is any possible value for the
signvariable which would make that if statement do anything other than raise aTypeError.but
"08:00:00" < "10:00:00". comparing timestamps as strings is weird but actually works, as long as the hour is zero-padded :)the problem with this code is that
&(bitwise AND) has higher operator precedence than>and==do, so it is first trying to bitwise AND"10:00:00"withsign(which i'm assuming would also be a string) and that will always raise aTypeError.to do what the author appears to have intended to do, they would either need use parenthesis around both comparisons to actually bitwise AND their results, or (better) to use the boolean AND operator (
and) instead of&.The boolean
andoperator is the right tool for the job, and since it is lower precedence it also wouldn't require that any parenthesis be added here.lengau@midwest.social · 4 pts · 187d
Heh you're right, I didn't catch the bitwise and, so I thought you were making a TypeError joke about comparing strings. Fixing the
andthough (which I did naturally when I typed it into my interpreter to double-check), we get the issue that they are just using a string for the time rather than a time object. "Too early" is also a valid entry that gets us an available office.themaninblack@lemmy.world · 25 pts · 187d
CVE score 9.9 vuln: slide sign halfway in between
webghost0101@sopuli.xyz · 18 pts · 188d
I once wrote down a food recept in code style because it seemed like the most structured way to do so.
Klear@quokk.au · 9 pts · 187d
Did you use this language?
Technoworcester@feddit.uk · 6 pts · 188d
Seems reasonable to me.
xtools@programming.dev · 4 pts · 187d
cooklang might be of interest for you then
Camille_Jamal@lemmy.zip · 1 pts · 179d
Me definitely not thinking in c++ while learning c++
otter@lemmy.dbzer0.com · 4 pts · 188d
Anyone else pause on the ! for "...to use" vs the . of "...in use"?