val
Version, currently 0.2.02 versions
- 0.2.0latestJan 15, 2017
- 0.1.0not indexedJan 15, 2017
github.com/maiha/val.cr
Scala-ish lazy `val`, `var` for Crystal
1 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
val:
github: maiha/val.cr
version: ~> 0.2.0Then run:
shards installshard.yml
- Crystal
- no constraint declared
- License
- MIT
- Author
- maiha
Dependencies
This version declares no dependencies.
README
val.cr 
Scala-ish lazy val, var for Crystal.
- crystal: 0.20.4
dependencies:
val:
github: maiha/val.cr
version: 0.2.0
Usage
require "val"
class Foo
val x = 1
var y = "123"
val z : Int32 = (a = [1]; a << 2; a.sum)
val cached? = true
end
foo = Foo.new
foo.x # => 1
foo.y = "xxx" # => "xxx"
foo.z # => 3
foo.cached? # => true
NOTE
val is almost same as getter except two points.
-
getterwith=evaulates code immediately, butvalruns lazily.
-
getterwith=fails with multiple lines, butvalaccepts it.
Although getter with block runs lazily, block format has less readability than =.
Contributing
- Fork it ( https://github.com/maiha/val.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- 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
0.2.0- Tagged
- Jan 15, 2017
- Commit
26de8bf7f1d3- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/maiha/val.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 2