Mailinglist Archive: yast-devel (144 mails)

< Previous Next >
[yast-devel] Slight incompatibility between Ruby and YCP

I think I found a slight incompatibility between Ruby and YCP

in YCP, I have the following code:

map btrfs = GetTargetMap()["/dev/btrfs"]:$[];
map ret = filter( map p, btrfs["partitions"]:[],

which, in case of an empty list returned by filter call, relies on default
parameter "$[]" after index operation.

In RUby this is:

btrfs = Ops.get(GetTargetMap(), "/dev/btrfs", {})
ret = Ops.get(
Builtins.filter(Ops.get_list(btrfs, "partitions", [])) do |p|
Ops.get_string(p, "uuid", "") == uuid

This works as before in assigning empty map to ret, but it now has the side
effect of a line being written to y2log stating:
[Ruby] yast/ops.rb:62 Index 0 is out of array size
while the equivalent YCP code did not create any y2log entries.

Is this intentional?
Depending on the number of occurrences of such accesses in YCP code it
could clutter y2log a lot.

Thomas Fehr
Thomas Fehr, SuSE Linux Products GmbH, Maxfeldstr. 5, 90409 Nuernberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imend├Ârffer, HRB 16746 (AG N├╝rnberg)
Tel: +49-911-74053-0, Fax: +49-911-74053-482, Email: fehr@xxxxxxx
GPG public key available.
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups