The Crystal programming language | http://crystal-lang.org | Fund Crystal's development: http://is.gd/X7PRtI | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/
0, 1, 3, ...
0, 1, 2, ...
*
Foo.new 1
or Foo.new id: 1
alias DeviceName = String
alias DeviceFile = Int32
alias DeviceDir = Hash(DeviceName, DeviceFile | DeviceDir)
pp Hash(DeviceName, DeviceDir).new
pp Hash(DeviceName, DeviceFile).new
pp DeviceDir.new
#=> 21 | pp DeviceDir.new
#=> ^--
#=> Error: undefined method 'new' for DeviceDir.class
DeviceDir
is an alias of Hash(DeviceName, DeviceFile | DeviceDir)
, why can't I call .new
on it?
related: crystal-lang/crystal#5155
recursive aliases are usually frowned upon, so might want to go to plan b