Skip to content

Instantly share code, notes, and snippets.

@icy
Created July 31, 2018 08:25
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 icy/64ec1838929d448d9f874d1e8261e56a to your computer and use it in GitHub Desktop.
Save icy/64ec1838929d448d9f874d1e8261e56a to your computer and use it in GitHub Desktop.
UFCS-unittest.d
auto foo(string[] sta) {
return sta;
}
auto bar(string[] sta) {
return sta;
}
auto h(string[] sta) {
return sta.foo.bar;
}
unittest {
import std.format;
auto f = (string[] sta) => sta.foo.bar;
auto g(string[] sta) {
return sta.foo.bar;
}
assert(f(["test"]) == ["test"]);
assert(g(["test"]) == ["test"]);
assert(["test"].h() == ["test"]);
assert(["test"].g == ["test"]);
/*
The latest test raises error: Error: no property g for type string[]
*/
}
@icy
Copy link
Author

icy commented Jul 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment