Skip to content

Instantly share code, notes, and snippets.

@Shaolo
Last active April 29, 2017 23:40
Show Gist options
  • Save Shaolo/4c7b155be9e06320ea578469b9022691 to your computer and use it in GitHub Desktop.
Save Shaolo/4c7b155be9e06320ea578469b9022691 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
//import Foundation
var Vin:Double = 400
var r1:Double = 100
var r2:Double = 5
var Vout:Double = Vin * (r1 / (r1 + r2))
print(Vout)
if let value = NSExpression(format: "Vin * (r1 / (r1+r2))")
.expressionValue(with: ["Vin":Vin,
"r1":r1,
"r2":r2],
context: nil) {
print(value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment