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.
%
. \$\endgroup\$