Convert PHP code into Ruby!
RSS icon Email icon Home icon
  • implode

    Posted on June 1st, 2009 RubyLove No comments

    The implode function takes and array and forms a string by concatenating the elements in the array.

    PHP

    $langs = array('python', 'java', 'ruby');
    $string = implode(', ', $langs);
    echo $string;
    // => python, java, ruby

    Ruby

    puts ['perl', 'python', 'java'].join(', ');
    # => python, java, ruby

    Leave a reply