From 9d07b3955fb2946e5588e7ec1f057b59437ffcc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Fri, 13 Jan 2023 16:05:39 +0100 Subject: [PATCH] v0.0.56 --- langext/bool.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/langext/bool.go b/langext/bool.go index cd00461..933cfe1 100644 --- a/langext/bool.go +++ b/langext/bool.go @@ -15,3 +15,35 @@ func Conditional[T any](v bool, resTrue T, resFalse T) T { return resFalse } } + +func ConditionalFn00[T any](v bool, resTrue T, resFalse T) T { + if v { + return resTrue + } else { + return resFalse + } +} + +func ConditionalFn10[T any](v bool, resTrue func() T, resFalse T) T { + if v { + return resTrue() + } else { + return resFalse + } +} + +func ConditionalFn01[T any](v bool, resTrue T, resFalse func() T) T { + if v { + return resTrue + } else { + return resFalse() + } +} + +func ConditionalFn11[T any](v bool, resTrue func() T, resFalse func() T) T { + if v { + return resTrue() + } else { + return resFalse() + } +}