Question: I have a select and a function bound to on change (ng-change), the thing is I want this function to work when the user clicks the already selected element, so they can easily reuse the already selected action.

This is my html (with [Slim](http://slim-lang.com/))

```
select ng-model="selectedAction" ng-options="action.label for action in Actions" ng-change="chooseAction()"
    option ng-selected="users.items.length == 0" value="" Select an Action

```

Is this possible or I'll have to add a button to make it work?

Already saw [this](https://stackoverflow.com/questions/5964362/select-already-selected-item-in-dropdown-select-list) and [this](https://stackoverflow.com/questions/3354367/html-select-element-onchange-trigger-for-already-selected-option), looking for another solution.

Answer: 
The left-hand expression must be a `String` to use the `=~` operator with a regular expression. Call `to_s` on `x` before testing against the regular expression:

```
def getValue(x) 
    puts "Key: #{x}"
    if x.to_s =~ /[0-9]+/
        puts "x is an int"
    else
        puts "x is a string"
    end
end

```

Also, method names in Ruby are `snake_case`, so `getValue` should be `get_value`.

Or you could just use `x.is_a? Integer` if you want to check the *type* of the value, not the *string representation*.

Regex advise: As Michael Berkowski mentioned, your regular expression will match a string that has a digit anywhere. You should anchor the pattern between `\A` (start of string) and `\Z` (end of string):

```
\A[0-9]+\Z

```

Even more nit-picking: the `[0-9]` character class is equivalent to the `\d` meta character, so you could do this as well:

```
\A\d+\Z

```
Use `is_a?` to inspect the type:

```
def getValue(x) 
    puts "Key: #{x}"
    if x.is_a?(Integer)
        puts "x is an int"
    else
        puts "x is a string"
    end
end

```

Output:

```
irb> getValue(1)
Key: 1
x is an int
irb> getValue("1")
Key: 1
x is a string

```