bluescreen10 / ternary

Ternary operator for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ternary

Ternary operator for Go

Usage

A ternary operator is a short version of an if-else statement that can make the code more readable for some use cases such is variable initialization:

import "github.com/bluescreen10/ternary"

function createServer(desiredPort int) {
    port := ternary.T( desiredPort > 0, desiredPort, 8080)
    // some code
}

About

Ternary operator for Go

License:MIT License


Languages

Language:Go 100.0%