dimanche 26 septembre 2021

An if statement returns a different variable on each branch, how can I assign to that variable using only one <- operator?

Consider

if(sample(2, 1) == 1) a <- 5 else b <- 5

This is repetitive. Is there any way to not have to write <- 5 twice?

Aucun commentaire:

Enregistrer un commentaire