Created
October 1, 2025 21:25
-
-
Save henri/0c0692d90cc3a53aba2d0d35d90acb4a to your computer and use it in GitHub Desktop.
negative space programming example snippits
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 characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment