Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created November 11, 2011 17:52
Show Gist options
  • Save Raynos/1358680 to your computer and use it in GitHub Desktop.
Save Raynos/1358680 to your computer and use it in GitHub Desktop.
// optional typing for function parameters
// Allows you to use a string literal in front of the variable name
// This string literal must be a valid [[Class]] value
// And the function when invoked should throw a type error if the argument passed // in doesn't have the correct [[Class]] value
// If an argument is not passed in, the function should not throw an error
function Func("Function" f, "Array" arr) {
return f(arr);
}
// Works
Func();
Func(function () { });
Func(function () { }, []);
// Fails
Func([]);
Func("foo");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment