Like in title – for example I have a method DrawMe(what) and I want to allow to run this method when what argument is equal to one of this values: {"house", "garden", "cat", "dog"} – and if not then this method should be stopped and an error should be printed. Any ideas?
Like in title – for example I have a method DrawMe(what) and I want
Share
However, note that most of the time you should not be ensuring that developers passed the right type of value into your method. Your method will raise its own error if something explodes as a result of misuse; it’s a waste of your time and the computer’s time to attempt to check and catch errors like this.
Edit: If you need to use this frequently, you could monkeypatch it in everywhere: