Multiple choice technology programming languages

Which function removes last character of a string?

  1. chop

  2. chomp

  3. delete

  4. chopp

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

chop removes the last character from a string and returns it. chomp (option B) specifically removes the input record separator (usually newline) only, making it safer for most use cases. chop is deprecated in favor of chomp for removing trailing newlines.