On Tue, Aug 13, Lukas Ocilka wrote:
On 08/13/2013 01:30 PM, Thomas Fehr wrote:
While I was just fixing a bug in current head and had to test the
fix anyway I assumed I could easily modify the ruby code needing
to be adapted anyway to a more ruby-like style.
I replaced the common usage of hash access with default parameter by
YCP Code --> Ruby like replacement
part["fsid"]:0 --> (part["fsid"]||0)
part["type"]:`none --> (part["type"]||:none)
This might cause a buggy behavior if the value was /false/ !
part["format"] = false
part.fetch("format", true) --> returns false
part["format"] || true --> returns true
I see, thanks for mentioning this.
So the above construct works for every type except bool.
Neverthless I rewrote it using method fetch (that so far I did not know)
Nice to see others did not know about fetch too ;-)
I haven't checked that but you can access string
as it was an array, so it
seems this might work well.
irb(main):001:0> a = "12345678901234567890"
Meanwhile I have found string method starts_with? which should be
more self explanatory for this special case.
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(a)suse.de
GPG public key available.
To unsubscribe, e-mail: yast-devel+unsubscribe(a)opensuse.org
To contact the owner, e-mail: yast-devel+owner(a)opensuse.org