Hey folks, I'm trying to get these bits of syntax to make sense to me:
S[] split(S)(S s) if (isSomeString!S)
{
...
}
and
string join(in string[] words, string sep)
{
...
}
(As seen in phobos/src/std/string.d
)
As far as I can tell, this is the piece of code that lets us do stuff like:
string[] parts = "/foo/bar/baz".split("/"); // string[] {"foo", "bar", "baz"}
string part = parts.join("-"); // string "foo-bar-baz"
Which basically makes me believe something like the extension methods I know from CSharp are possible in d. The problems I have are:
- That I'm not 100% sure i'm looking at the right function declarations here
- That I don't see what makes them similar.