https://github.com/nobodywasishere/guard.cr
https://github.com/nobodywasishere/guard.cr
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/nobodywasishere/guard.cr
- Owner: nobodywasishere
- License: mit
- Created: 2023-09-30T20:30:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-30T20:30:53.000Z (over 1 year ago)
- Last Synced: 2025-05-13T13:19:53.695Z (about 1 month ago)
- Language: Crystal
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# guard
Add Swift's [guard clause](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/statements/#Guard-Statement) as a macro to Crystal.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
guard:
github: nobodywasishere/guard
```2. Run `shards install`
## Usage
```crystal
require "guard"def normalize(value : Int32?)
guard value do
return 0
endvalue
endnormalize(1) # => 1
normalize(nil) # => 0
```## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Contributors
- [Margret Riegert](https://github.com/nobodywasishere) - creator and maintainer