Yukihiro "Matz" Matsumoto
d6dc9caa02
mruby-hash-ext/hash.rb: make transform_keys! to keep old keys
...
```ruby
h={1=>2,2=>3}
h.transform_keys!{_1.succ}
```
used to make `h` to `{2=>2}` (duplicated keys were squashed), but now
makes it `{2=>2,3=>3}`.
2022-12-14 07:39:10 +09:00
John Bampton
ea8964ef35
ruby: standardize whitespace
2022-10-31 16:25:56 +10:00
Yukihiro "Matz" Matsumoto
3b55a09f91
mruby-hash-ext/hash.c (hash_values_at): early return from the function.
2022-10-21 13:41:38 +09:00
Yukihiro "Matz" Matsumoto
d2a24a540c
hash.c: implement typical part of merge in C.
2022-06-19 22:28:31 +09:00
Yukihiro "Matz" Matsumoto
909e1044ed
mruby-hash-ext/hash.rb (merge!): takes multiple arguments.
2022-06-18 16:12:14 +09:00
dearblue
2d0b50f6f3
Avoid warnings with ruby -cw
...
```console
% for rb in `git ls-files '*/mrblib/*.rb' 'mrblib'`; do ruby30 -cw $rb > /dev/null; done
mrbgems/mruby-array-ext/mrblib/array.rb:389: warning: assigned but unused variable - ary
mrbgems/mruby-array-ext/mrblib/array.rb:663: warning: assigned but unused variable - len
mrbgems/mruby-hash-ext/mrblib/hash.rb:119: warning: possibly useless use of a variable in void context
mrbgems/mruby-hash-ext/mrblib/hash.rb:259: warning: assigned but unused variable - keys
mrbgems/mruby-io/mrblib/io.rb:229: warning: literal in condition
mrbgems/mruby-io/mrblib/io.rb:280: warning: literal in condition
mrbgems/mruby-string-ext/mrblib/string.rb:347: warning: assigned but unused variable - len
mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb:2: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
```
2021-06-28 23:21:47 +09:00
John Bampton
d55a74c418
feat(CI): check for trailing whitespace
...
Run on pull request only.
Use a shell script to check for trailing whitespace in all files.
Fail if trailing whitespace is found.
2021-02-13 16:37:46 +10:00
Seeker
14a92f9705
Add Hash#except [Ruby 3.0]
2020-12-27 16:33:12 -08:00
dearblue
f0a64329b1
Prohibit array changes by "a"/"*" specifier of mrb_get_args()
...
The "a"/"*" specifier of the `mrb_get_args()` function will now return `const mrb_value *`.
This is because it is difficult for the caller to check if it is an array object and write-barrier if necessary.
And it requires calling `mrb_ary_modify()` on the unmodified array object, which is also difficult (this is similar to #5087 ).
2020-10-22 22:55:35 +09:00
Yukihiro "Matz" Matsumoto
fc8fb41451
Small refactoring in hash_slice; ref #4926
2020-01-10 17:57:33 +09:00
KOBAYASHI Shuji
ac213907d7
Remove unneeded dependency from mruby-hash-ext
2019-11-08 20:40:20 +09:00
KOBAYASHI Shuji
ea2424d36d
Drop test dependency from mruby-hash-ext to mruby-enumerator
2019-11-06 18:57:35 +09:00
Yukihiro "Matz" Matsumoto
57a0132b41
Add filter aliases for Enumerable and Hash.
2019-09-16 10:10:09 +09:00
Yukihiro "Matz" Matsumoto
610bcc88c2
Removed to_hash conversion method.
2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto
5bbcea9b3b
Removed try_convert method from Array and Hash.
2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto
8ffd4e47fb
Use mrb_undef_value for delete mark instead of shifting Hash entry table.
...
That means entry table should be compacted periodically by `sg_compact()`.
2018-09-26 23:09:48 +09:00
Yukihiro "Matz" Matsumoto
3820ef791f
Small refactoring in mruby-hash-ext.
2018-09-20 09:07:24 +09:00
Yukihiro "Matz" Matsumoto
62e8e910b2
Reimplement Hash#compact! to conform the standard behavior.
...
`Hash#compact!` should return `nil` if the receiver does not change.
2018-08-06 16:40:19 +09:00
Yukihiro "Matz" Matsumoto
ad17ba0e11
KeyError from Hash#fetch should inspect key.
...
To distinguish string keys and symbol keys.
2017-12-25 23:52:40 +09:00
Yukihiro "Matz" Matsumoto
421819dc2c
Add Hash#slice [Ruby 2.5]
2017-12-25 23:43:37 +09:00
Yukihiro "Matz" Matsumoto
df68a3345d
assert_equal() takes result as the first argument
2017-12-25 15:39:45 +09:00
Yukihiro "Matz" Matsumoto
ce916b99b8
Add Hash#to_proc; CRuby2.3
2017-10-18 10:18:43 +09:00
Yukihiro "Matz" Matsumoto
44f07045d1
Add Hash#fetch_values; CRuby2.3
2017-10-18 10:05:39 +09:00
Clayton Smith
5dc688fb12
Check whether internal khash is initialized in Hash#compact!
2017-08-17 12:13:41 -04:00
Yukihiro "Matz" Matsumoto
9826ca54f2
VM stack may be reallocated during mrb_hash_get; fix #3771
2017-08-10 08:21:43 +09:00
Yukihiro "Matz" Matsumoto
6c61a60609
Implement Hash#compact! in C; ref #3769
2017-08-09 21:20:50 +09:00
vvakame
4d46f366ac
add method(compact, compact!) and test of Hash to mruby-hash-ext
2017-08-09 19:18:02 +09:00
Christopher Aue
3359b86ec7
Improved speed of enumeration methods
2017-07-30 13:19:31 +02:00
Yukihiro "Matz" Matsumoto
515a093213
Add Hash#transform_keys! and Hash#transform_values.
2017-07-15 08:51:35 +09:00
Yukihiro "Matz" Matsumoto
d7fef24a95
Use keys.each instead of unstable each_keys.
2017-07-15 08:50:52 +09:00
Yukihiro "Matz" Matsumoto
460d628490
Remove duplication in mruby-hash-ext test.
2017-07-14 16:10:26 +09:00
Yukihiro "Matz" Matsumoto
de3edcc170
Add Hash#transform_{keys,values} to mruby-hash-ext.
2017-07-14 15:13:41 +09:00
Yukihiro "Matz" Matsumoto
a18904a4c2
Use "$!" specifier of mrb_get_args.
2017-07-12 14:49:55 +09:00
Kouhei Sutou
e72e50b5d5
Hash sub class creates new sub class objects instead of Hash
2017-03-21 23:25:36 +09:00
Yukihiro "Matz" Matsumoto
817b884343
add #dig tests
2016-03-23 12:34:32 +09:00
Yukihiro "Matz" Matsumoto
daf83946bb
add #dig to Array,Hash and Struct
2016-03-23 11:49:28 +09:00
Yukihiro "Matz" Matsumoto
5c405dea3d
include changed from by quotes ("") to by brackets (<>); close #3032
2015-11-27 17:48:23 +09:00
takahashim
621487a0cd
add {Array|Hash|String}.try_convert
2015-11-24 08:39:39 +09:00
Yukihiro "Matz" Matsumoto
fa86026a99
move Hash comparison methods to mruby-hash-ext gem
2015-11-15 05:15:20 +09:00
Seba Gamboa
25c8e95365
Revert "Mark core gems with mrbgem tag"
...
This reverts commit 5cdcce8dbd .
2015-10-21 14:31:13 -03:00
Seba Gamboa
13b552538a
Remove obvious warnings from docs
2015-10-20 12:48:31 -03:00
Seba Gamboa
5cdcce8dbd
Mark core gems with mrbgem tag
2015-10-20 12:16:47 -03:00
Jun Hiroe
570c261555
Refator Hash.fetch test
2015-09-26 09:58:36 +09:00
Asmod4n
4bd98671bc
Problem: Hash#fetch doesn't raise KeyError when a key cannot be found
...
Solution: change the Exception class raised to KeyError when a key
cannot be found.
2015-09-17 13:28:09 +02:00
takahashim
b88ca625ab
fix block variable in Hash#fetch
2015-09-16 02:57:41 +09:00
Jun Hiroe
4e4929bc72
Rename extended xxxx class or module to xxxx class or module extension
2015-06-28 11:18:52 +09:00
Jun Hiroe
c69d1201e1
Fix typo; Replace extensional with extended
2015-06-28 00:05:58 +09:00
Franck Verrot
2588507285
Remove unnecessary backticks.
...
Dr Markus Kuhn published in 1999 an article [1] explaining in details
why we shouldn't use the ASCII grave accent (0x60) as a left quotation.
Backticks have been used most notably to produce nice-looking LaTeX
documents but it doesn't seem to be an issue on modern platforms and
for the oldest ones, there are workarounds as mentioned by Dr Kuhn.
[1]: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
2015-06-24 13:07:07 +02:00
Yukihiro "Matz" Matsumoto
50f54529f2
to_hash/to_a check in Hash[] should only be done when only one argument is given; ref #2594
2014-09-19 01:14:50 +09:00
INOUE Yasuyuki
5f16c41753
copy documentation comment from CRuby
2014-09-18 17:43:38 +09:00