I have the following program in Swift (myscript.swift
):
print("Enter x: ");
var x = readLine()!
print("x is " + x)
print("Enter y: ");
var y = readLine()!
print("y is " + y)
And I have an input file that contains the following (input.txt
):
4
6
Usually, I compile using swift myscript.swift
. However, I want to compile by passing the input file so that I am not prompted for input at the terminal. Is there a way to achieve this?