That's how it done in Wolfram Language with %
symbol. For example:
RandomInteger[{120, 600}]^2 // 55225
Sqrt[%] // 255
It would be cool to have something similar in Swift playgrounds. A symbol for referring the previous answer without assigning it to a variable. For example $
. Like:
func square(_ x: Int) -> Int {
return x * x
}
square(Int.random(in: 120...600)) // 30625
sqrt($) // 175
If you don't understand why it's useful, you are probably use playground only for programming. But imagine using playground as a big calculator. Such feature is extremely helpful for playing with calculations. And also for education, when students need to do a big task separated into smaller parts.