Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### [OK] 1.rb
- ```ruby
- require "json"
- def convert_to_json(obj)
- obj.to_json
- end
- p convert_to_json(1) # => "1"
- p convert_to_json("x") # => "\"x\""
- ```
- ```console
- % ruby 1.rb
- "1"
- "\"x\""
- % crystal 1.rb
- "1"
- "\"x\""
- ```
Add Comment
Please, Sign In to add comment