greenbigfrog has quit [Read error: Connection reset by peer]
<oprypin>
bew, relyks, instead of that you can just use 'p'
<oprypin>
(p [1,2,3]).sum
<oprypin>
puts and pp might work the same way but i don't remember
hightower4 has joined #crystal-lang
<hightower4>
Hey, how can I split a string "a:b" on ":" but keep ":" in the results? I.e. I want the split to result in ["a", ":", "b"], rather than in ["a", "b"]. (Something similar to what splitting on word boundaries would do (using \b), but I need it for a few select characters, not everything that \b would match
<hightower4>
Ah, seems like look-behind would work, e.g. (?<=\:)
<oprypin>
do you really want them there? you know that every 2nd item is :
<oprypin>
use that fact in the consumer code
<hightower4>
oprypin, yes but I've simplified the example
<oprypin>
ok. but you need both lookahead and lookbehind
<hightower>
Is there a 'case' syntax which allows me to match if 'case' value is part of some array? Like case my_word; when array.includes_it
eperez has joined #crystal-lang
<Groogy>
don't think so?
<Groogy>
why wouldn't you just do if array.includes? my_word
<Groogy>
?
dragonkh has quit [Ping timeout: 265 seconds]
rohitpaulk has joined #crystal-lang
<hightower>
Because this is just one of the cases. I have a whole list of 'whens'
<hightower>
And if I would need to alternate between ifs and cases, and make sure that if some if or when was matched, further processing would stop (just like a single case..end list of statements would do)
<hightower>
s/And if/And/
<Groogy>
you mean like if/elsif/else/end?
<Groogy>
you could also just put the things you want to match against iwth an array and then cross check the arrays
<Groogy>
make it more procedural
<Groogy>
You also have some nifty operators like ~ to get the difference between two arrays etc.
<Groogy>
Eh I mean &
<Groogy>
& will get you the intersection of two arrays
<Groogy>
meaning you get only the elements that match in both
<hightower>
Groogy, I mean, I can write case str; when "X", "Y", "Z", but apparently can't write case str; when some_array
<Groogy>
yeah because case str will be matching str with "X", "Y", "Z"
<Groogy>
as if you were writing an if/elsif etc.
<Groogy>
Either way what are you trying to compare?
<Groogy>
because when some_array doesn't really make sense since it would be the same as just checking some_array.includes? str
<hightower>
Yes I agree with you, but I said I'd prefer the case..end method because then I can have a long list of 'when's, rather than having to do some if-elses, then some case-ends, then some if-elses etc.
<Groogy>
yeah but all of those cases have the same data type right?
<Groogy>
put it into a data structure and loop over it and then delegate to functions what to do
<Groogy>
it's gona be way prettier anyway
<crystal-gh>
[crystal] RX14 opened pull request #5553: Simplify Crystal::System interface by adding File.stat? and lstat? (master...feature/file-stat-cleanup) https://git.io/vNkPU
<hightower>
I'll just convert the whole thing to if-elses
<Groogy>
avoid primitive obsession ;D
<Groogy>
eh no? It would be a loop where you delegate to an object what to do
<Groogy>
or a struct
<Groogy>
"Here's the data, do something with it" and it decides if it fits for it or not
<Groogy>
why are there pics of girls on the posts though? :confused:
<FromGitter>
<bew> No idea ˆˆ
rohitpaulk has quit [Ping timeout: 248 seconds]
<lvmbdv>
might be an SEO thing
<lvmbdv>
and that blog might be stealing post text from other geniune posts
<lvmbdv>
^ long shot
<lvmbdv>
or just poor aesthetics
DTZUZO has quit [Ping timeout: 265 seconds]
<Groogy>
or 13 years old? ¯\(°_o)/¯
eperez has joined #crystal-lang
eperez has quit [Ping timeout: 248 seconds]
faustinoaq_ has joined #crystal-lang
<faustinoaq_>
or just a java developer with a busy job :)
faustinoaq_ has quit [Client Quit]
rohitpaulk has joined #crystal-lang
cbass has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
eperez has joined #crystal-lang
ashirase has quit [Ping timeout: 248 seconds]
tilpner has quit [Read error: Connection reset by peer]
tilpner has joined #crystal-lang
ashirase has joined #crystal-lang
Groogy has quit [Quit: WeeChat 2.0]
eperez has quit [Ping timeout: 265 seconds]
<lvmbdv>
sorry if this is asked a lot here, are there any more documentation on recursive types (aliases)?
DTZUZO has joined #crystal-lang
dragonkh has joined #crystal-lang
DTZUZO has quit [Ping timeout: 260 seconds]
alex`` has quit [Ping timeout: 252 seconds]
alex`` has joined #crystal-lang
jdnoodle has quit [Quit: leaving]
A124 has quit [Ping timeout: 255 seconds]
eperez has joined #crystal-lang
Ven`` has joined #crystal-lang
Ven`` has quit [Ping timeout: 264 seconds]
Ven`` has joined #crystal-lang
A124 has joined #crystal-lang
alex`` has quit [Quit: WeeChat 1.9]
Ven`` has quit [Ping timeout: 276 seconds]
Ven`` has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 265 seconds]
Ven`` has quit [Ping timeout: 265 seconds]
Ven`` has joined #crystal-lang
fellow has joined #crystal-lang
snsei has joined #crystal-lang
<fellow>
with #sort you can sort arrays by the alphabet. So im sure theres some Const in crystal which is having the alphabet which is used by #sort. wheres this const?
<RX14>
fellow, there's no such array
<RX14>
ASCII defines that the way characters are represented as numbers is already ordered by the alphabet
<fellow>
oooh..
<RX14>
so if you order by numerical order you order by lexical order too
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eperez has joined #crystal-lang
byteflame has joined #crystal-lang
hmans has joined #crystal-lang
eperez has quit [Ping timeout: 264 seconds]
rohitpaulk has quit [Ping timeout: 265 seconds]
eperez has joined #crystal-lang
<lvmbdv>
crystal is so damn comfy
<lvmbdv>
thank you all
<lvmbdv>
just squeezed some experimentation before bed time
<lvmbdv>
good night~
<ua>
yeah its awesome, i dont even feel bad about betraying ruby
<ua>
cheating on?
<ua>
xD
<FromGitter>
<bew> Why does this compiles? `Pointer(Int32).null.as(Array(Bool))` I would expect the `.as` to say that I can't cast `Pointer(Int32)` to `Array(Bool)`
<FromGitter>
<bew> note: `Int32` & `Array(Bool)` are randomly choosen types
<oprypin>
bew, Pointer.as is a special case that does no checking
<oprypin>
it's needed for low level operations
<oprypin>
see also: Box
<FromGitter>
<bew> oh ok, but now we have `.unsafe_as` I think that `Pointer#as` should be normal, and if really needed, `unsafe_as` should be used
eperez has quit [Ping timeout: 265 seconds]
eperez has joined #crystal-lang
eperez has quit [Ping timeout: 240 seconds]
eperez has joined #crystal-lang
<FromGitter>
<bew> well no, nvm (`unsafe_as` is itself a method, implemented using this unchecked `as` on pointer)