More elegant and abstract approaches are described below.
更加優雅和抽象的方法描述如下。