codeinabox@programming.dev to Programming@programming.devEnglish · 1 day agoI keep tripping over “true, false, true”allthingssmitty.comexternal-linkmessage-square29fedilinkarrow-up162arrow-down11
arrow-up161arrow-down1external-linkI keep tripping over “true, false, true”allthingssmitty.comcodeinabox@programming.dev to Programming@programming.devEnglish · 1 day agomessage-square29fedilink
minus-squareFizzyOrange@programming.devlinkfedilinkarrow-up1·2 hours 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.