Al declarar una variable de parámetro de tipo Double en Swift, se produjo la siguiente excepción al realizar operaciones.
Binary operator '*' cannot be applied to two 'Double?' operands
Situación uno
Los tipos de parámetros no coinciden, los tipos de parámetros deben coincidir
self.max = height / (length * width) // 初始
self.max = height / (length * Double(width)) // 改后
Situación 2
La variable del parámetro de definición inicial puede estar vacía, agregar una condición en blanco y agregar el carácter "!" al final del parámetro declarado
let length = Double(self.lengthText)!
let width = Double(self.weightText)!
let height = Double(self.heightText)!
self.max = height / (length * width)
Lo anterior es todo el contenido compartido esta vez, ¡espero que pueda ser de ayuda para todos!