Interesting Bit of Code

By: Johnathon Wright on: February 11, 2020

Whenever I see screen shots of code, I think that my code isn't interesting enough to create a visual. I do tend to write small bits that are simple-looking (to my eyes.) So when writing this bit, I thought I'd record it for posterity in case I wanted something in the future.

def looks_numeric?
  number = "-?\\s*\\d{0,}[\\.\\,]{0,2}(\\d{1,})?"
  numeric_value_pattern = /^\s*#{number}\s*$/
  numeric_range_pattern = /^\s*#{number}\s*-\s*#{number}\s*$/

  numeric_value_pattern =~ self ||
    numeric_range_pattern =~ self ||
      Inequality.pattern =~ self


Just checking that you are human. What would be the result of this code?

a = 3*(4/2); b = 1; a+b