Przeglądaj źródła

Added Alias to user types

Alan Rawkins 8 lat temu
rodzic
commit
2fe9585dc3
1 zmienionych plików z 20 dodań i 0 usunięć
  1. 20 0
      modules/monkey/docs/language/user-types.md

+ 20 - 0
modules/monkey/docs/language/user-types.md

@@ -231,3 +231,23 @@ Class Foo
 	Field _somePrivateThing:String
 End
 ```
+
+#### Alias
+
+An `Alias` allows you to create a synonym for a previously declared type.
+
+<div class=syntax>
+`Alias` _Identifier_ `:` _Type_
+</div>
+
+<br>
+You can use your newly declared `Alias` instead of the original type anywhere in your code. For example:
+
+
+```
+Alias FantasticNumber:Int
+Alias FantasticString:String
+
+Local myInt:FantasticNumber = 123
+Local myString:FantasticString = "abc"
+```