No joke I totally love for its match syntax.

Checking for three environment variables, returning the first match and returning a standard if none matched:


Well we can even get rid of the variables and just do

return match ...

@Nervengift true! I always forget about removing `return` and final `;` in Rust :D

@kevin if you want a more functional approach, you can also write it like this:

(And if you're okay with eager evaluation, you can even skip the closures by using .or(..) and .unwrap_or(..) )

@zatnosk thanks! Others recommended this, too. I didn't know about .or() before! :)

Sign in to participate in the conversation
Mastodon is a instance for everyone who is part of bullgit. 🎉