-
-
Save ravicious/50712 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mam dwie tablice: | |
# a = [1,2] | |
# b = [3,4], | |
# chce je polaczyc w nastepujacy sposob: [[1,3],[2,4]] | |
# pytam wiec irba jak to zrobic :-) | |
>> a = [1,2] | |
=> [1, 2] | |
>> b = [3,4] | |
=> [3, 4] | |
>> a.what?(b) == [[1,3],[2,4]] | |
[1, 2].zip([3, 4]) == [[1, 3], [2, 4]] | |
=> ["zip"] | |
=> 1.240 seconds :) | |
>> a | |
=> [1, 2] | |
>> a.zip(b) | |
=> [[1, 3], [2, 4]] | |
# inny przyklad: | |
>> c = (1..3).to_a | |
=> [1, 2, 3] | |
>> c.what? == [3,2,1] | |
[1, 2, 3].reverse! == [3, 2, 1] | |
[1, 2, 3].reverse == [3, 2, 1] | |
=> ["reverse!", "reverse"] | |
# kolejny: | |
>> " abc ".what? == "abc" | |
" abc ".strip! == "abc" | |
" abc ".strip == "abc" | |
=> ["strip!", "strip"] | |
# to jest piekne ;-) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment