PHP 7.2 : how to replace DEPRECATED create_function to pass a var ?

create_function is now obsolete with PHP 7.2. How to rewrite it with anonymous function to pass a var in add_action() at end of a function calculating this var ? In this case, ‘admin_notices’ action display a message when the theme is activated.

Replace

add_action( 'admin_notices', create_function( '', 'echo "' . addcslashes( $msg, '"' ) . '";' ) );

by

add_action(
    'admin_notices',
    function() use ( &$msg ) {
       echo $msg;
    }
);

Note that var used by references ( &$msg ) in function.
See the functions.php to this theme in GitHub ( line 148 ).

Enjoy