🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

unionvalue

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unionvalue

1.1.0
Rubygems
Version published
Maintainers
1
Created
Source

unionvalue

Allows easy creation of immutable union values, a.k.a. sum-types.

You can think of them as enums (enumerated types) that can also contain other data.

Example:

APICallResult = UnionValue.new(:success, :failure, :timeout)
APICallResult.failure.is_failure? #=> true
APICallResult.timeout.is_success? #=> false
APICallResult.success(12345).data #=> 12345

Normal classes with attributes act as 'product' types. In other words, their number of possible values are the product of the number of possible values of all their attributes. Sum-types are instead just the sum of their attributes values. In other words, they can have this attributes OR this other attribute, but not both.

Read more about sum-types here: https://en.wikipedia.org/wiki/Sum_type

Copyright (c) 2015 Axis Sivitz. See LICENSE.txt for further details.

FAQs

Package last updated on 01 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts