class Single
{
public array $data = [];
public static $instance;
PRIVATE function __construct()
{
}
public static function getInstance()
{
if (empty(self::$instance)) {
self::$instance = new Single();
}
return self::$instance;
}
public function __get(string $key)
{
return $this->data[$key]??null;
}
public function __set(string $key, $value)
{
$this->data[$key] = $value;
}
}
class A
{
public static function tryW()
{
Single::getInstance()->some = 1;
}
}
class B
{
public static function tryR()
{
var_dump(Single::getInstance()->some);
}
}
$a = new A();
$a->tryW();
$b = new B();
$b->tryR();
func (c *pods) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Pod, err error)
println("Какой у тебя вес ?")
val weight : Double = readln().toDouble()
println("Какой у тебя рост ?")
val height : Double = readln().toDouble()
println("Какой у вас пол ? муж -1 , жен - 2")
val year : Double = readln().toDouble()
val w: Double = 10.0
val h: Double = 6.25
val h2: Double = 5.0
val calc = w * weight + h * height - h2 * year + h2
И как вы обычно меняете работу?