If this is written in multiple lines of code, it is indeed 空指针保护
But in your question, there is only this line in the whole method, this trick should be called Caching with Instance Variables, in order to improve the performance when calling this method multiple times
If this is written in multiple lines of code, it is indeed
空指针保护
But in your question, there is only this line in the whole method, this trick should be called
Caching with Instance Variables
, in order to improve the performance when calling this method multiple timesThis is a common approach among Ruby programmers:
空指针保护
.