Drupal-friendly var_export() in Drupal 8

When developing in Drupal 8, I used the drupal_var_export() function a lot to print arrays to the screen so I could then copy and paste into code to create the same array. This saved me a lot of time. In Drupal 8 the drupal_var_export function no longer exists. Instead do the following:

dsm(\Drupal\Component\Utility\Variable::export($array_to_output));

Obviously you need the Devel module enabled.