var
Version, currently 1.0.07 versions
github.com/maiha/var.cr
`Object.var` macro for Crystal
3 stars
1 dependent
License: MIT
Nothing has been indexed for 1.0.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
var:
github: maiha/var.cr
version: ~> 1.0.0Then run:
shards installshard.yml
No shard.yml has been indexed for 1.0.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# var.cr [](https://travis-ci.org/maiha/var.cr)
`var` provides a macro that gives a lazy evaluation to the `property` variable.
Users are freed from ugly `not_nil!` and tired `not initialized` constraints
and can write simple code.
- [tested versions](./ci)
## Usage
```crystal
require "var"
class Sample
var foo = true
var bar : Int32 = build_bar
var baz : String
var counts = Hash(String, Int32).new
private def build_bar
1
end
end
obj = Sample.new
obj.foo? # => true
obj.foo # => true
obj.bar? # => 1
obj.bar # => 1
obj.baz? # => nil
obj.baz # raises "var `baz` is not set yet." (Var::NotReady)
obj.baz = "a"
obj.baz # => "a"
obj.baz = nil # `nil` assignments are always ignored
obj.baz # => "a"
obj.counts["a"] = 1
obj.counts # => {"a" => 1}
```
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
var:
github: maiha/var.cr
version: 1.3.0
```
## Development
```shell
make ci
```
## Contributing
1. Fork it ( https://github.com/maiha/var.cr/fork )
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
- [maiha](https://github.com/maiha) maiha - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
1.0.0- Tagged
- Aug 1, 2021
- Commit
0bb29ccf2096- Indexed
- not yet
Dependents
Repository
github.com/maiha/var.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 7