Skip to content

Instantly share code, notes, and snippets.

@joseoliv
Created June 25, 2019 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseoliv/9325a00416fbb36b47cd1843c0548ce5 to your computer and use it in GitHub Desktop.
Save joseoliv/9325a00416fbb36b47cd1843c0548ce5 to your computer and use it in GitHub Desktop.
getProgramValueFromKey
package metaobjectTest
@doc{*
Annotation 'getProgramValueFromKey' is String expression. It is
"" if its parameter is not a program key. If it is, the expression
is the value associated to the key in the program but
transformed into a string by either method toString of Java or
method asString of Cyan.
*}
object GetProgramValueFromKey
func run {
/*
The project file, p.pyan, has the contents
@setVariable(debug, "yes")
@setVariable(author, "Jose")
// elided
program
// elided
@setVariable(test, create)
@setVariable(goal, "Test all metaobjects")
package metaobjectTest
// elided
Therefore the program variable 'debug' is associated
to "yes" and 'author' to "Jose".
*/
var String value = @getProgramValueFromKey(debug);
assert value == "yes";
value = @getProgramValueFromKey(author);
assert value == "Jose";
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment