On Tuesday, 28 April 2015 at 21:45:10 UTC, PhilipDaniels wrote:
Beginner question. Given

  if (startsWith(input, "0x", "0X"))

How do I turn that into a case-insensitive startsWith? startsWith says it takes a predicate but I can't figure out how to pass it one. The examples all use "a == b" !? These attempts below, and other things I have tried, fail with "cannot deduce function from argument types".

  if (startsWith!"icmp(a, b) == 0"(input, "0x"))
  if (startsWith!"std.uni.icmp(a, b) == 0"(input, "0x"))
  if (startsWith!((a,b) => icmp(a,b) == 0)(input, "0x"))

I believe the issue is that the predicate expects a boolean, icmp returns an int. Try a == toLower(b) as your predicate(there's probably a better solution somewhere hidden in phobos though.)

Reply via email to