Created
August 18, 2025 21:29
-
-
Save oeo/d935cd75a86eff7cd5689b5bb3805ed3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Prototypical ideas for syntax improvements | |
| // Range loops | |
| for x in [1..10] { | |
| console.log x | |
| } | |
| // List comprehensions | |
| const evens = [x * 2 for x in [1..100] if x % 2 == 0] | |
| // Pattern matching | |
| match value { | |
| case 0 => "zero" | |
| case 1..10 => "small" | |
| case n if n > 100 => "large" | |
| case _ => "medium" | |
| } | |
| // Pipeline operators | |
| const result = data | |
| |> filter(x => x > 0) | |
| |> map(x => x * 2) | |
| |> reduce((a, b) => a + b) | |
| // Guard clauses | |
| guard user.isValid else throw "Invalid user" | |
| // Async do notation | |
| const data = do { | |
| user <- await fetchUser() | |
| posts <- await fetchPosts(user.id) | |
| return { user, posts } | |
| } | |
| // Object spread pattern matching | |
| const {x, y, ...rest} := point | |
| // Optional chaining existential operators with defaults | |
| const name = user?.profile?.name ?? "Anonymous" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment