In reply to dave_59:
Thank you! To help me understand better, can you let me know how different is the it with regards to below task:
task task_name(variable_item_name a);
if(a.enable == 1) begin
a.val1 = $urandom_range(10);
a.val2 = $urandom(15);
end
endtask: task_name
If essence is same what is the purpose of casting in the above task?