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
- Host: GitHub
- URL: https://github.com/jw3126/single.jl
- Owner: jw3126
- License: other
- Created: 2018-06-07T18:47:22.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-07T18:57:59.000Z (about 8 years ago)
- Last Synced: 2025-04-05T04:26:57.244Z (about 1 year ago)
- Topics: julia
- Language: Julia
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Single

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"
```