An open API service indexing awesome lists of open source software.

https://github.com/jw3126/single.jl

Contains single function
https://github.com/jw3126/single.jl

julia

Last synced: 11 months ago
JSON representation

Contains single function

Awesome Lists containing this project

README

          

# Single
![](https://travis-ci.org/jw3126/Single.jl.svg?branch=master)

Return the single element of a container. Stolen from [here](https://github.com/JuliaLang/julia/pull/25078).

```julia
julia> using Single

julia> single([])
ERROR: ArgumentError: Collection is empty, must contain exactly one element

julia> single(["TheHighlander"])
"TheHighlander"

julia> single([1,2])
ERROR: ArgumentError: Collection has multiple elements, must contain exactly one element

julia> single([], "default")
"default"
```