mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
28 lines
406 B
Swift
28 lines
406 B
Swift
public class BaseProblem
|
|
{
|
|
func run() -> Int
|
|
{
|
|
return 0
|
|
}
|
|
}
|
|
|
|
class Evaluator
|
|
{
|
|
var map: [Int: () -> Int] = [:]
|
|
|
|
init()
|
|
{
|
|
map[1] = { Problem1().run() }
|
|
map[2] = { Problem2().run() }
|
|
}
|
|
|
|
func evaluate(_ n: Int)
|
|
{
|
|
if let problemBlock = map[n]
|
|
{
|
|
let foo = problemBlock()
|
|
print("foo = \(foo)")
|
|
}
|
|
}
|
|
}
|