Here i am listing examples of extending methods using specman e-language concept.
Ex : extending using is_also
---> Filename packet.e
<’
struct packet_s {
my_method () is {
out (“I am here”);
};
};
‘>
-------> new file packet_extend.e
<’
import packet.e;
extend packet_s {
my_method () is also {
out("to learn e-language”);
};
};
‘>
when we execute the packet_extend.e we can see finally the output appearing as "I am here to learn e-language".
Ex : extend using is first
---> Filename packet.e
<’
struct packet_s {
my_method () is {
out (“I am here”);
};
};
'>
---> New file : packet_extend.e
<’
import packet_extend.e;
extend packet_s {
my_method () is first {
out (“to learn e-language”);
};
};
'>
when we execute the packet_extend.e we can see finally the output appearing as "to learn e-language i am here".
Ex: extend using is only
---> Filename packet.e
<’
struct packet_s {
my_method () is {
out (“I am here”); }; };
'>
---> New file packet_extend.e
<’
import packet.e;
extend transaction_s {
my_method () is only {
out (“to learn e-language”);
};
};
'>
when we execute the packet_extend.e we can see finally the output appearing as "to learn e-language ", this extend method operator overrules the previous contents of the same method defined.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment