Skip to content

damonchen/o

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

o

ternary operator for golang, only for the same return type

example

import (
	"github.com/damonchen/o"
)

v := o.T(p == nil, "not exist", "exits")

lazy evaluate

import (
	"github.com/damonchen/o"
)

v := o.L(p == nil, o.W("not exist"), o.W("exist"))

complicated example

import (
	"github.com/damonchen/o"
)

v := o.L(p == nil, o.W("unknown"), func() string{
	return o.T(p.gender == 1 ? "man": "women")
})