Skip to content

Instantly share code, notes, and snippets.

@weberc2
Created May 7, 2015 12:40
Show Gist options
  • Save weberc2/4131654ff068d27f9cde to your computer and use it in GitHub Desktop.
Save weberc2/4131654ff068d27f9cde to your computer and use it in GitHub Desktop.
public bool string_compare(string a, string b) {
return a == b;
}
public bool template_compare<T>(T a, T b) {
return a == b;
}
public string bool_to_str(bool val) {
return val ? "true" : "false";
}
public void main() {
string a = "abcd";
string b = "abcd";
// compare strings with string_compare
string string_compare_result = bool_to_str(string_compare(a, b));
stdout.printf("string_compare(%s, %s): %s\n", a, b, string_compare_result);
// compare strings with template_compare
string template_compare_result = bool_to_str(template_compare<string>(a, b));
stdout.printf("template_compare(%s, %s): %s\n", a, b, template_compare_result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment