https://github.com/nickrobison/else-let
Clojure macro for conditional letting of variables
https://github.com/nickrobison/else-let
Last synced: over 1 year ago
JSON representation
Clojure macro for conditional letting of variables
- Host: GitHub
- URL: https://github.com/nickrobison/else-let
- Owner: nickrobison
- License: epl-1.0
- Created: 2018-03-25T01:04:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-25T01:20:27.000Z (over 8 years ago)
- Last Synced: 2024-10-19T05:22:31.002Z (almost 2 years ago)
- Language: Clojure
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/nickrobison/else-let)
[](https://opensource.org/licenses/EPL-1.0)
[](https://clojars.org/else-let)
# else-let
A Clojure library that adds an `else-let` macro for conditional binding in the face of `nil` values.
Inspired by Java's `Optional.orElseGet()` method, this macro evaluates the provided let statement and attempts to bind the variables to the first provided form,
if that form returns `nil`, `else-let` will bind the value of the second form.
Example:
```clojure
(else-let [x "first-value" "fallback"
y nil "will bind this value to y"
z nil nil]
(vector x y (nil? z)))
;["first-value" "will bind this value to y" true]
```
## Usage
###
```clojure
[else-let "0.1.0"]
```
### Maven
```xml
else-let
else-let
0.1.0
```
## License
Copyright © 2018 Nick Robison
Distributed under the Eclipse Public License version 1.0