Reputation: 39457
I'm working on a string-to-bool parsing function for Haxe (somehow the devs got by until now without one >.<) and i figured the best way to check the string would be ignoring case. I'm not sure how to do that though, can someone help me?
Upvotes: 2
Views: 1924
Reputation: 411
Just incase anybody needs copy and paste.
function StringToBool(a:Dynamic):Bool{
var res:Bool = (cast (a, String).toLowerCase() == "true")?true:false;
return res;
}
Upvotes: -2
Reputation: 4430
In std there is not such a function but you can easily add your own:
public static function equalsCI(a : String, b : String) return a.toLowerCase() == b.toLowerCase();
Upvotes: 4