We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 897b0e3 commit 05b7896Copy full SHA for 05b7896
logic_go1.18.go
@@ -0,0 +1,26 @@
1
+//go:build go1.18
2
+
3
+package com
4
5
+import "reflect"
6
7
+func IfTrue[V any](condition bool, yesValue V, noValue V) V {
8
+ if condition {
9
+ return yesValue
10
+ }
11
+ return noValue
12
+}
13
14
+func IfFalse[V any](condition bool, yesValue V, noValue V) V {
15
+ if !condition {
16
17
18
19
20
21
+func IfZero[V any](condition any, yesValue V, noValue V) V {
22
+ if reflect.ValueOf(condition).IsZero() {
23
24
25
26
0 commit comments