【文件属性】:
文件名称:try.cr:尝试monad水晶
文件大小:7KB
文件格式:ZIP
更新时间:2021-05-11 00:16:18
Crystal
try.cr
尝试monad for 。
:
用法
require " try "
i = Try ( Int32 ).try { 1 } # => Success(Int32)
i.get # => 1
i.err # raises "not failed"
i.value # => 1
i.map( & . + 1 ).value # => 2
i = Try ( Int32 ).try { raise " error " } # => Failure(Int32)
i.get
【文件预览】:
try.cr-master
----ci(327B)
----src()
--------try.cr(4KB)
----spec()
--------spec_helper.cr(36B)
--------match_spec.cr(2KB)
--------try_spec.cr(4KB)
--------case_in_spec.cr(277B)
--------example_spec.cr(1KB)
----.travis.yml(70B)
----LICENSE(1KB)
----shard.yml(75B)
----README.md(2KB)
----Makefile(1KB)
----.gitignore(165B)