!9IQChSjwSHXPPWTa:lix.systems

Lix

1103 Members
Lix user channel. Feel free to discuss on-topic issues here and give each other help. For matrix.to links to the rest of the Lix channels, see: https://wiki.lix.systems/books/lix-organisation/page/matrix-rooms294 Servers

You have reached the beginning of time (for this room).


SenderMessageTime
12 Oct 2025
@sofiedotcafe:matrix.orgSofie 🏳️‍⚧️ (she/her)

What is the shortest syntax to do something like

if condition then "arf arf :3" else "meowww :3"
17:03:11
@sofiedotcafe:matrix.orgSofie 🏳️‍⚧️ (she/her)that syntax for me is kinda bulky17:03:34
@stephen:crabsin.spacen3tcatlix ternary operator when17:07:52
@vczf:matrix.orgvczfI would like a ternary operator in nix17:08:04
@bandithedoge:matrix.orgbandithedogeexactly this17:12:02
@aloisw:julia0815.dealoisw
In reply to @stephen:crabsin.space
lix ternary operator when
if then else is the ternary operator.
17:31:52
@stephen:crabsin.spacen3tcat"good ternary operator when" then17:38:47
@charles:computer.surgeryCharlesWhat makes a ternary operator good?17:42:28
@charles:computer.surgeryCharlesForgettable syntax like in C?17:42:51
@vczf:matrix.orgvczf foo ? a : b operator chains well in dart/flutter for complex widget trees. Nix attrsets have a similar structure, so I think it would be a good fit 17:42:58
@stephen:crabsin.spacen3tcathow is it any more forgettable than % for modulus or * for multiplication or anything else?17:43:41
@stephen:crabsin.spacen3tcatidk that feels like a nitpick to me17:43:45
@vczf:matrix.orgvczfIf dart had inline if-then-else it would be unreadable17:43:55
@aftix:matrix.orgaftix
  • is used for literally everything, people who have never programmed can immediately see * is multiplication
17:44:39
@stephen:crabsin.spacen3tcatthat may be true, I'm not sure17:45:42
@stephen:crabsin.spacen3tcatIs the same true for %?17:45:45
@stephen:crabsin.spacen3tcator || or &&?17:45:51
@stephen:crabsin.spacen3tcatlike was there a point to pick on * or did you legitimately not get the point I was making lol17:46:18
@charles:computer.surgeryCharles When I was learning programming I struggled to remember the respective meaning of the second and third expression in C's ternary operator. Didn't have this problem with if. I think the only reason a language would want/need a dedicated ternary operator other than if it would be because the language forces those constructs to be statements (C) rather than allowing them to be expressions (Rust). If if is already useable as an expression, a ternary operator would be redundant 17:48:11
@stephen:crabsin.spacen3tcatI personally don't really have an issue with redundancy. Python tried to do the "only have 1 way to do things" philosophy and it was a disaster. No switch statements etc17:49:07
@charles:computer.surgeryCharlesRedacted or Malformed Event17:49:16
@stephen:crabsin.spacen3tcatlol17:49:24
@charles:computer.surgeryCharlesOn third thought it's actually fine17:49:42
@charles:computer.surgeryCharles* On third thought it's actually fine (re: redacted message)17:49:58
@stephen:crabsin.spacen3tcat anyway I personally don't think it's a huge issue either way since if is an expression like you said, but yeah I would prefer the ? : syntax 17:49:57
@charles:computer.surgeryCharles
In reply to @stephen:crabsin.space
I personally don't really have an issue with redundancy. Python tried to do the "only have 1 way to do things" philosophy and it was a disaster. No switch statements etc
Python has match since 3.13 or something now
17:50:27
@stephen:crabsin.spacen3tcatYeah I know17:50:41
@stephen:crabsin.spacen3tcatbut for a long time they didn't17:50:44
@stephen:crabsin.spacen3tcatand when you complained they'd be like "in python there should only be 1 way to do things"17:50:55

Show newer messages


Back to Room ListRoom Version: 10