In Groovy, there is a nice syntax for working with null values.
For example, I can do an if statement:
if (obj1?.obj2?.value) {
}
This will not throw a NullPointerException even if obj1 is null (it will evaluate to false).
This is something that's very convenient, so wondering if there is a Ruby equivalent I missed.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…