Created
October 1, 2025 21:25
-
-
Save henri/0c0692d90cc3a53aba2d0d35d90acb4a to your computer and use it in GitHub Desktop.
Revisions
-
henri created this gist
Oct 1, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ def calculate_area(width, height) raise TypeError, "Width must be a number" unless width.is_a?(Numeric) raise TypeError, "Height must be a number" unless height.is_a?(Numeric) raise ArgumentError, "Width must be positive" unless width > 0 raise ArgumentError, "Height must be positive" unless height > 0 width * height end # Usage: calculate_area(10, 20) # works fine calculate_area(-5, 10) # raises ArgumentError