In Specman I can convert a variable to a string using either:
x.to_string();
or
x.as_a(string);
Is there any difference between the two? If not, why does Specman provide both?
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.
as_a()allows you to convert the expression to a specific type, not only string.These are few examples from the docs
UPDATE:
using
as_a(string)andto_string()not always gives the same results.This will print something like this:
This is because
to_stringwill run on each element of the list and then the list will be concatenated with spaces,as_awill however convert integers to characters and concatenate them, giving you thehelloword.