Skip to content

Instantly share code, notes, and snippets.

@Kdan
Last active January 26, 2021 14:15
Show Gist options
  • Select an option

  • Save Kdan/dcaa97a0b729431cd4f86e27b05c5c80 to your computer and use it in GitHub Desktop.

Select an option

Save Kdan/dcaa97a0b729431cd4f86e27b05c5c80 to your computer and use it in GitHub Desktop.
class FunctionCall: Hashable {
/// The name of the function
let name: FunctionName
/// The number of calls for the function.
var numberOfCalls: Int { calls.count }
/// The parameters sent to the function.
private(set) var calls = [Any?]()
init(name: FunctionName) {
self.name = name
}
/// Append a call to the function with the given parameters.
/// - Parameter parameters: The parameters to append.
func append<T>(_ parameters: T?) {
calls.append(parameters)
}
static func == (lhs: FunctionCall, rhs: FunctionCall) -> Bool {
lhs.name == rhs.name
}
public func hash(into hasher: inout Hasher) {
hasher.combine(name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment