Skip to content

Commit

Permalink
Do not assign nil to string.length (#1833)
Browse files Browse the repository at this point in the history
  • Loading branch information
janbiedermann authored and iliabylich committed May 27, 2018
1 parent 3d46dd4 commit 3bd7e24
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions opal/corelib/string.rb
Expand Up @@ -280,8 +280,8 @@ def center(width, padstr = ' ')
return self if `width <= self.length`

%x{
var ljustified = #{ljust ((width + @length) / 2).ceil, padstr},
rjustified = #{rjust ((width + @length) / 2).floor, padstr};
var ljustified = #{ljust ((width + `self.length`) / 2).ceil, padstr},
rjustified = #{rjust ((width + `self.length`) / 2).floor, padstr};
return self.$$cast(rjustified + ljustified.slice(self.length));
}
Expand Down

0 comments on commit 3bd7e24

Please sign in to comment.