Created
November 3, 2025 15:54
-
-
Save fractaledmind/5343efdfe96a835b5fbbcc40f491a687 to your computer and use it in GitHub Desktop.
Some basic examples of the Empirical gem syntax enhancements
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
| fun method_name => void do | |
| # ... | |
| end | |
| fun method_name => never do | |
| # ... | |
| end | |
| fun method_name => Integer do | |
| # ... | |
| end | |
| fun method_name => _Integer(10..) do | |
| end | |
| fun method_name(named_param: String) => void do | |
| end | |
| fun method_name(positional_param = String) => void do | |
| end | |
| fun method_name(arg_splat = [String]) => void do | |
| end | |
| fun method_name(kwarg_splat: { String => Integer }) => void do | |
| end | |
| fun method_name(optional_named_param?: String) => void do | |
| end | |
| fun method_name(optional_positional_param?: String) => void do | |
| end | |
| # ----- | |
| overload fun example(input = String) => String do | |
| "Called with a string" | |
| end | |
| overload fun example(input = Integer) => String do | |
| "Called with an integer" | |
| end | |
| # ----- | |
| class User | |
| prop :name, String, reader: :public, writer: :public | |
| def good | |
| @name = "Hello" | |
| end | |
| def bad | |
| @name = 1 | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment