Jack Kelly Jack Kelly - 1 year ago 258
Ruby Question

What does 'no implicit conversion of Regexp into String (TypeError)' mean?

class String
def digit?

Test.assert_equals "".digit?, false
Test.assert_equals "7".digit?, true
Test.assert_equals " ".digit?, false

I have been playing around with regular expressions. Can you tell me how I have made an error? I have tried explicitly converting it to a string but it doesn't work nor do I see why I should have to. Could anyone enlighten me? Thank you!

Answer Source

include? expects a string as documented here. It seems like you were looking for match.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download