Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 426 Bytes

File metadata and controls

17 lines (14 loc) · 426 Bytes

Inferred Types

A variable declaration in a for-each loop can make use of var to infer its type.

~class Main {
~   void main() {
String[] chairMaterials = { "wicker", "wood", "plastic" }
for (var chairMaterial : chairMaterials) {
    IO.println(chairMaterial);
}
~   }
~}

And this is good to know for the same reasons you would use var other places in Java. Writing Book book can be a drain on the soul.