type_constraints:类型约束

时间:2024-07-21 16:45:35
【文件属性】:

文件名称:type_constraints:类型约束

文件大小:10KB

文件格式:ZIP

更新时间:2024-07-21 16:45:35

Ruby

类型约束 用法 require "type_constraints" TypeConstraints . setup do type :Array do constraint -> v { v . kind_of? ( Array ) } end subtype :ArrayOfString , :Array do constraint -> v { v . all? ( ) { | v | v . kind_of? ( String ) } } end subtype :ArrayOfHisa , :ArrayOfString do constraint -> v { v . all? ( ) { | v | v === "5518" } } end end puts "testing Array" p TypeConstraints .


【文件预览】:
type_constraints-master
----.gitignore(118B)
----README.md(2KB)
----Gemfile(101B)
----.rspec(31B)
----spec()
--------type_constraints_spec.rb(2KB)
--------type_constraints()
--------spec_helper.rb(86B)
----type_constraints.gemspec(966B)
----LICENSE.txt(1KB)
----.travis.yml(30B)
----lib()
--------type_constraints.rb(663B)
--------type_constraints()
----Rakefile(118B)

网友评论