Skip to content

Instantly share code, notes, and snippets.

@joseoliv
Last active August 30, 2022 08:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save joseoliv/a993fa5495e34ad6bb6b9a78f366511c to your computer and use it in GitHub Desktop.
Metaobject addMethodTo
package metaobjectTest
@addMethodTo("func zero -> Int", "func zero -> Int = 0;")
@addMethodTo(
"""func len: String s less: Int -> Int""",
"""
func len: String s less: Int n -> Int { return s size - n}
""")
object AddMethodTo
func run {
assert zero == 0;
assert self len: "abcde" less: 2 == 3;
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment