Merge: lib/core/bytes: Add a redef of has method
authorJean Privat <jean@pryen.org>
Fri, 7 Jun 2019 17:16:29 +0000 (13:16 -0400)
committerJean Privat <jean@pryen.org>
Fri, 7 Jun 2019 17:16:29 +0000 (13:16 -0400)
Adding the redef of the `has` method  to take care of the negative numbers

Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>

Pull-Request: #2749
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>

lib/core/bytes.nit

index f386c47..3013321 100644 (file)
@@ -538,6 +538,12 @@ class Bytes
                length += cln
        end
 
+       redef fun has(c)
+       do
+               if not c isa Int then return false
+               return super(c&255)
+       end
+
        #     var b = new Bytes.empty
        #     b.append([104, 101, 108, 108, 111])
        #     assert b.to_s == "hello"