Validate arguments in Ruby? -
I wonder if anyone should validate that the argument passed to a method is of a certain class.
For example, "first logic needs to be a hash", unless "hash.clash == hash" does not require second argument, then DF type (hash = { }, Valid = []) # Validate to be an array "until the array.class == array # real code expiration
Whether it is smart to do or passes in debates Is it just time and time to validate all of them?
Is there any such situation when you have this extra Safety and circumstances when you will not bother
Share your experiences!
response_to?
with method method? To implement the word: [], it is worth it. OpenStruct hash economics and attribute-accessory method words, but condition hash.class == hash
. It will act like a hash in practice, though.
To keep it in perspective, even in a non-dynamic language, you do not want to do this; You would like to verify that any object applied to IDictionary & lt; T & gt;
Ruby idioms will like that, when necessary, you verify that the law exists, because if this happens, the developer probably intends to work their purpose equally.
Comments
Post a Comment