Can you trim the trailing space `{% set class = (loop.first ? 'home') ~ (loop.last ? 'current') %}` 
and add it only after `{% set class = class ~ ' ' ~value %} `