DEV Community

Discussion on: Daily Challenge #310 - Boolean to String Conversion

Collapse
nijeesh4all profile image
Nijeesh Joshy • Edited on

Ruby

there already exists a function to_s.

If you want another one, here it is

def bool_to_s(str)
  (!!str).to_s
end
Enter fullscreen mode Exit fullscreen mode

It will work without the !! I just wanted to make sure it will work even if anything else is passed