codeinabox@programming.dev to Programming@programming.devEnglish · 19 days agoI keep tripping over “true, false, true”allthingssmitty.comexternal-linkmessage-square25linkfedilinkarrow-up161arrow-down11cross-posted to: hackernews@lemmy.bestiver.se
arrow-up160arrow-down1external-linkI keep tripping over “true, false, true”allthingssmitty.comcodeinabox@programming.dev to Programming@programming.devEnglish · 19 days agomessage-square25linkfedilinkcross-posted to: hackernews@lemmy.bestiver.se
minus-squareFizzyOrange@programming.devlinkfedilinkarrow-up1·18 days agoYeah I do wonder if we need an easier way to declare these things because programmers are lazy and even in Rust I wouldn’t always bother. You can kind of do it in Typescript with strings: function create_user(role: "admin" | "normal") But of course the downside is they are strings at runtime. I’m sure it’s possible though.
Yeah I do wonder if we need an easier way to declare these things because programmers are lazy and even in Rust I wouldn’t always bother.
You can kind of do it in Typescript with strings:
function create_user(role: "admin" | "normal")But of course the downside is they are strings at runtime. I’m sure it’s possible though.