Mega Code Archive

 
Categories / Ruby / String
 

Reverse a string in or not in place

s = ".sdrawkcab si gnirts sihT" puts s.reverse                              puts s s.reverse!                            # => "This string is backwards." puts s                                # => "This string is backwards."