# Is using the Swift REPL for my answer valid? [duplicate]

This is a very strange hack that I came across the other day. In the Swift REPL, if I create an instance of any type (say for example, a String), it automatically gets assigned to a variable in the same way an argument to a closure is. The name used is \$R{n}. Here is an example:

However, this only works in the REPL. So I can I use this hack in a Swift answer if I specify that you have to run it like this:

cat file.swift | swift

Note that you do get extra output in the form of the blue output in the REPL.

• This belongs on our meta site, and I have voted to migrate. – Okx Aug 25 '17 at 16:12
• I think yes, because Mathematica REPL is valid. (although that is (probably) the default way to run MMA). MMA "last output" is even shorter, %. – user202729 Aug 25 '17 at 16:14
• You can, if your language is "Swift REPL", not "Swift". Also, might want to migrate this to meta. – Mr. Xcoder Aug 25 '17 at 16:17

# Yes, but Swift and Swift REPL are different.

Yes, you are allowed to use all the features of REPL Swift (Terminal Swift), as long as you specify that your language is Swift REPL, not Swift. For example, your header should not look like this:

#Swift, X bytes


#Swift REPL, X bytes

cat file.swift | swift

If you include cat file.swift | swift in your byte count (i.e. <program bytes> + X bytes (for cat file.swift | swift))