एक user-defined type guard हा असा फंक्शन आहे ज्याचा return type हा एक type predicate (x is T) असतो. जेव्हा तो true रिटर्न करतो, तेव्हा compiler argument ला T मध्ये narrowing करतो calling code मध्ये — यामुळे तुम्ही custom runtime checks encapsulate करू शकता.
