# Ruby: no implicit conversion of String into Integer

**URL:** <https://discuss.elastic.co/t/ruby-no-implicit-conversion-of-string-into-integer/181054>\
**Category:** Logstash\
**Created:** [May 14, 2019, 5:53pm UTC](https://discuss.elastic.co/t/ruby-no-implicit-conversion-of-string-into-integer/181054 "2019-05-14T17:53:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [May 14, 2019, 5:53pm UTC](https://discuss.elastic.co/t/ruby-no-implicit-conversion-of-string-into-integer/181054/1 "2019-05-14T17:53:58Z")

</div>

This is my code  
First I am changing them to integer  
then if they are nil assign them 0  
and then do calculation.

```
mutate {
      convert => { "killo" => "integer" }
      convert => { "trace" => "integer" }
   }

if ![killo] {
  mutate {update => { "kilo" => 0 } }
   }
   if ![trace] {
  mutate {update => { "trace" => 0 } }
   }

ruby {
      code => "event.set('total',(event.get('kilo')*event.get('trace')))"
   }

```

and I get this error

"ruby - Ruby exception occurred: no implicit conversion of String into Integer"

What I am doing wrong?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 14, 2019, 5:56pm UTC](https://discuss.elastic.co/t/ruby-no-implicit-conversion-of-string-into-integer/181054/2 "2019-05-14T17:56:09Z")

</div>

You seem to have a mix of `kilo` and `killo` in the config. Is this on purpose?

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [May 14, 2019, 5:58pm UTC](https://discuss.elastic.co/t/ruby-no-implicit-conversion-of-string-into-integer/181054/3 "2019-05-14T17:58:41Z")

</div>

Ohhh man. yes that was typo.

Cool. I reran after fixing that and it works. Thank you

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 11, 2019, 5:58pm UTC](https://discuss.elastic.co/t/ruby-no-implicit-conversion-of-string-into-integer/181054/4 "2019-06-11T17:58:47Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
