如何在表达式语法中调用变量(Object)的方法? [Twig Templating]

How to call a variable's method in expression syntax in twig tempting system. see the example below

{{ myObj.someMethod() }} {# this print the output of this method #}

i don't want above code because its printing output of this method. but i want this

{% myObj.someMethod() %}

but its is giving me error that

Unknown tag name "myObj" in "
{% myObj.someMethod() %}" at line 2

even with above error method is also being called.

In twig syntax {{ some variable}} will print the result in variable you need to set variable and then use where you want

{% set myvar = myObj.someMethod() %}  /* this will store the result returned from function */

{{ myvar }} /* this will print the result in myvar */