Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
C0D4681387yArrested? That’s to kind after that. I’m just digging a hole and loading a gun
π π« β°οΈ -
You can shorten the double ternary to
x == 0 && y > 0 ? y - 1: y
Not that much better but better -
@akhrameev it is, but op said he is building a text editor and i assumed y will always be >0. If that's not true then you're right and you need to use y!=0
-
@YouAreAPIRate your assumption was correct, and that would be a better way of doing it
-
Awlex182757y@YouAreAPIRate if we're talking about C, could not just use "!x" or "!y"?
Everything besides 0 is "true" anyways. Notice the quotation, because booleans have no real place in C. -
@Awlex you could. But if y is defined as uint the compiler will generate the same code and y>0 is better to understand. In the end it comes down to personal preference. And i rather do other things than discuss style
-
I read it really quick. Does it move the cursor to the beginning of the next line if it's at the end of the current one? Or back one line if it's at the beginning of a line? Something like that?
-
Awlex182757y@YouAreAPIRate better not talk about personal preferences, because i would have written something like this for the first parameter:
y - !(x|y)
π -
@Awlex i dont think that works in c, because thats a binary or. If x and y are greater than 1 then x|y could be too. But ++ for the idea
-
mechtecs27yDid that shit in 9th & 10th grade (currently 12). I liked it because then the tasks were a challenge and you can fuck off your teacher xD
-
@irene sorry maybe the irony didn't come through in that one.
Yes it would make it harder to read. That's why he should have done it to make the line itself also harder to read. -
@irene well looks like I blaimed you for not spotting my irony while I didn't spot yours π¬
I just wrote:
move((x==0?(y==0?y:y-1):y),(x==0?0:x-1));
I should be arrested
rant
obfuscating c code