File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
docs/docs/reference/metaprogramming Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,25 @@ constant expressions in the sense defined by the [SLS §
228
228
including _ platform-specific_ extensions such as constant folding of pure
229
229
numeric computations.
230
230
231
+ An inline value must have a literal type such as ` 1 ` or ` true ` .
232
+ ``` scala
233
+ inline val four = 4
234
+ // equivalent to
235
+ inline val four : 4 = 4
236
+ ```
237
+
238
+ It is also possible to have inline vals with primitives that do not have a syntactical version such as ` Short ` .
239
+
240
+ ``` scala
241
+ trait InlineConstants {
242
+ inline val myShort : Short
243
+ }
244
+
245
+ object Constants extends InlineConstants {
246
+ inline val myShort /* : Short(4)*/ = 4
247
+ }
248
+ ```
249
+
231
250
## Transparent Inline Methods
232
251
233
252
Inline methods can additionally be declared ` transparent ` .
You can’t perform that action at this time.
0 commit comments