I have code as below:
var s : String = "hello world"
var xml : XML;
try {
xml = new XML(s);
} catch (e:TypeError) {
trace("get a typeError");
}
but I don’t see it gets into the catch block.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
XML()accepts anything (*) in its constructor:So no, it does not throw a
TypeError.Note you don’t actually need to use the
newkeyword for creating instances ofXML:This may also be of interest for you – from
XML()– Top level function: