How do you multiply two variables in swift? [closed]

(1, 10) is of the type (Int, Int), which has no built in * function.

You can define one and it will work.

//: Playground - noun: a place where people can play

import Cocoa

func *(lhs: (Int, Int), rhs: (Int, Int)) -> (Int, Int) {
    return (lhs.0 * rhs.0, lhs.1 * rhs.1)
}

var multiplication1 = (2, 3)
var multiplication2 = (2, 3)

var answer_m = multiplication1 * multiplication2

Leave a Comment