How can I print current user role in Twig? I'm trying to get my user role thanks to a function in my theme.theme file.

function theme_get_user_role(){
  $current_user = \Drupal::currentUser();
  $roles = $current_user-&gt;getRoles();
}


then in my view : 

{% set roles = theme_get_user_role() %}
{{ dump(roles) }}


But I have this error : 


  Twig_Error_Syntax : Unknown "theme_get_user_role" function. dans
  Twig_ExpressionParser->getFunctionNodeClass()


What do I miss ?
You can use below without any function. Because the User module provides the variable in preprocess for all templates: :

{% set roles = user.getroles(TRUE) %}
{{ dump(roles) }}


If you want to do anything only for the particular role then do this:

{% if 'ROLENAME' in user.getroles(TRUE)  %}
  &lt;p&gt;The user has the role "ABC".&lt;/p&gt;
{% endif %}