Nasal Snippets: Difference between revisions
Jump to navigation
Jump to search
m (→Dumping all keys in a hash: grow stub) |
(Fixed typo in example code.) |
||
Line 22: | Line 22: | ||
if (typeof(hash) != "hash") die("dump_keys(): Error! Argument is not a hash."); | if (typeof(hash) != "hash") die("dump_keys(): Error! Argument is not a hash."); | ||
foreach(var key; keys(hash)){ | foreach(var key; keys(hash)){ | ||
print( | print(key, ": ", typeof(hash[key])); | ||
} | } | ||
} | } |
Latest revision as of 22:34, 13 June 2019
This article is a stub. You can help the wiki by expanding it. |
This page is meant to collect commonly used or otherwise useful Nasal snippets for use in FlightGear. Ideally, this will help new users to get started programming in Nasal more easily.
If you have any Nasal specific questions, you will want to check out Nasal FAQ. Feel free to ask new questions, help answer, refine existing ones.
Calling a function with named arguments
var sayHello = func(name) {
print("Hello ", name);
}
sayHello(name: "FlightGear");
Dumping all keys in a hash
var dump_keys = func(hash) {
if (typeof(hash) != "hash") die("dump_keys(): Error! Argument is not a hash.");
foreach(var key; keys(hash)){
print(key, ": ", typeof(hash[key]));
}
}