Skip to content

@m2mtech m2mtech released this Apr 22, 2017 · 8 commits to master since this release

Now that you allow variables to be entered as operands, add a method to evaluate the CalculatorBrain (i.e. calculate its result) by substituting values for those variables found in a supplied Dictionary ...

func evaluate(using variables: Dictionary<String,Double>? = nil)
      -> (result: Double?, isPending: Bool, description: String)

Note that this takes an Optional Dictionary (with Strings as keys and Doubles as values) as its argument and that that argument defaults to nil if not supplied when this method is called. Also note that it returns a tuple (the first element of which is an Optional Double). This method is not mutating and you are not allowed to make it so. If a variable that has been set as an operand is not found in the Dictionary, assume its value is zero.

https://cs193p.m2m.at/cs193p-assignment-2-task-4-winter-2017/

Assets 2
You can’t perform that action at this time.