diff options
| author | 2026-02-02 00:35:54 +0300 | |
|---|---|---|
| committer | 2026-02-02 00:35:54 +0300 | |
| commit | bfdd73d7324a4f66a16f55d4fb064b0ff08d40e9 (patch) | |
| tree | 27fff9c802dcdd22960bb2e776e58278000d0364 /content/posts/2024-12-15-conditional-operator-go | |
| parent | Поправил шаблон (diff) | |
| download | blog-bfdd73d7324a4f66a16f55d4fb064b0ff08d40e9.tar.gz blog-bfdd73d7324a4f66a16f55d4fb064b0ff08d40e9.tar.bz2 blog-bfdd73d7324a4f66a16f55d4fb064b0ff08d40e9.tar.xz blog-bfdd73d7324a4f66a16f55d4fb064b0ff08d40e9.zip | |
Большая чистка блога
Diffstat (limited to 'content/posts/2024-12-15-conditional-operator-go')
| -rw-r--r-- | content/posts/2024-12-15-conditional-operator-go/conditional-operator-go_ternary.webp | bin | 0 -> 7408 bytes | |||
| -rw-r--r-- | content/posts/2024-12-15-conditional-operator-go/index.md | 35 |
2 files changed, 35 insertions, 0 deletions
diff --git a/content/posts/2024-12-15-conditional-operator-go/conditional-operator-go_ternary.webp b/content/posts/2024-12-15-conditional-operator-go/conditional-operator-go_ternary.webp Binary files differnew file mode 100644 index 0000000..5eeea58 --- /dev/null +++ b/content/posts/2024-12-15-conditional-operator-go/conditional-operator-go_ternary.webp diff --git a/content/posts/2024-12-15-conditional-operator-go/index.md b/content/posts/2024-12-15-conditional-operator-go/index.md new file mode 100644 index 0000000..edbd1ef --- /dev/null +++ b/content/posts/2024-12-15-conditional-operator-go/index.md @@ -0,0 +1,35 @@ +--- +categories: + - Без рубрики +date: "2024-12-15T23:47:08+03:00" +description: "" +image: conditional-operator-go_ternary.webp +location: Казань +tags: + - IT + - Go +title: Тернарник в Go +--- + +Хотите немного ~~наркомании~~ сахара для Go? + +Их есть у меня: + +Тернарный оператор для Go на генериках + +```go +func If[T any](condition bool, thn T, els T) T { + if condition { + return thn + } + return els +} +``` + +[Плейграунд чтобы потыкать](https://go.dev/play/p/sBDnPGHce8I) + +Будет настроение — добавлю в свою либку https://neonxp.ru/go/extra , а пока, +как-то так держите. + +**Не стоит** использовать в реальном коде. Я лично не вижу никакого оправдания +для использования, кроме как покекать. |
