|
1 | 1 | package monkstone.vecmath.vec2; |
2 | 2 |
|
3 | | -/* |
| 3 | +/* |
4 | 4 | * Copyright (c) 2015-17 Martin Prout |
5 | | -* |
| 5 | +* |
6 | 6 | * This library is free software; you can redistribute it and/or |
7 | 7 | * modify it under the terms of the GNU Lesser General Public |
8 | 8 | * License as published by the Free Software Foundation; either |
9 | 9 | * version 2.1 of the License, or (at your option) any later version. |
10 | | -* |
| 10 | +* |
11 | 11 | * http://creativecommons.org/licenses/LGPL/2.1/ |
12 | | -* |
| 12 | +* |
13 | 13 | * This library is distributed in the hope that it will be useful, |
14 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | 16 | * Lesser General Public License for more details. |
17 | | -* |
| 17 | +* |
18 | 18 | * You should have received a copy of the GNU Lesser General Public |
19 | 19 | * License along with this library; if not, write to the Free Software |
20 | 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
@@ -153,9 +153,11 @@ public IRubyObject aset(ThreadContext context, IRubyObject key, IRubyObject valu |
153 | 153 | Ruby runtime = context.runtime; |
154 | 154 | if (key instanceof RubySymbol) { |
155 | 155 | if (key == RubySymbol.newSymbol(runtime, "x")) { |
156 | | - return runtime.newFloat(jx); |
| 156 | + jx = (value instanceof RubyFloat) |
| 157 | + ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue(); |
157 | 158 | } else if (key == RubySymbol.newSymbol(runtime, "y")) { |
158 | | - return runtime.newFloat(jy); |
| 159 | + jy = (value instanceof RubyFloat) |
| 160 | + ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue(); |
159 | 161 | } |
160 | 162 | } else { |
161 | 163 | throw runtime.newIndexError("invalid key"); |
|
0 commit comments