Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions src/calling-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,6 @@ def main(): Unit \ IO =
println(Math.abs(-123.456f64))
```

## Calling Constructors or Methods with VarArgs

We can call a constructor or method that takes variable arguments using the
special syntax `...{ value1, value2, ...}`. For example:

```flix
import java.nio.file.Path

def getMyPhoto(): Path \ IO =
Path.of("Documents", ...{"Images", "me.jpg"})
```

Here we call the `Path.of` Java method which requires a single string and then
a varargs array of strings.

In the special case where we want to call a constructor or method without any
varargs we have to explicitly pass an empty `Vector[t]`. Moreover, we have to
specify the type of the elements. For example:

```
import java.nio.file.Path

def getDocuments(): Path \ IO =
Path.of("Documents", (Vector.empty(): Vector[String]))
```

## When Constructor or Method Resolution Fails

In some cases the Flix compiler is unable to determine what Java constructor or
Expand Down
Loading