RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <epoch> yep appreciate the help @Blacksmoke16 @bew
<FromGitter> <Blacksmoke16> np
ternarysolo has joined #crystal-lang
ternarysolo has quit [Ping timeout: 240 seconds]
laaron has joined #crystal-lang
xaxisx has quit [Ping timeout: 245 seconds]
laaron- has quit [Ping timeout: 256 seconds]
xaxisx has joined #crystal-lang
xaxisx has quit [Ping timeout: 250 seconds]
xaxisx has joined #crystal-lang
Raimondi has quit [Quit: WeeChat 2.3: ¡Chau!]
smurfendrek123 has joined #crystal-lang
<smurfendrek123> Hello, can I pass a type as an argument? I want to write a method that converts the current type to a new type.
xaxisx has quit [Read error: Connection reset by peer]
<smurfendrek123> I discovered that i just have to say it's type is class, but can I specify the type of the class down to subclasses of a certain class?
ternarysolo has joined #crystal-lang
ternarysolo has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
crystal-lang564 has quit [Ping timeout: 258 seconds]
<smurfendrek123> When using array.new(size, value) can i still specify the type of the array? I want to fill it with nil, but it's type has to be String|Nil
chemist69 has quit [Ping timeout: 252 seconds]
chemist69 has joined #crystal-lang
<FromGitter> <maiha> `Array(String?).new(3, nil)` ?
<smurfendrek123> maiha, that works, thanks!
<smurfendrek123> Can someone explain this error to me? https://bpaste.net/show/f6ff613a0689
<smurfendrek123> I don't understand why that | doesn't work?
rohitpaulk has joined #crystal-lang
<smurfendrek123> Ah, i think the problem was that i thought there were order of operations on the logical operators, where == came before |
smurfendrek123 has quit [Remote host closed the connection]
<FromGitter> <maiha> `||` ?
ternarysolo has joined #crystal-lang
ternarysolo has quit [Ping timeout: 268 seconds]
crystal-lang564 has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
ternarysolo has joined #crystal-lang
return0e has quit [Ping timeout: 272 seconds]
return0e has joined #crystal-lang
ternarysolo has quit [Ping timeout: 244 seconds]
crystal-lang564 has quit [Quit: Konversation terminated!]
crystal-lang564 has joined #crystal-lang
ternarysolo has joined #crystal-lang
ternarysolo has quit [Ping timeout: 246 seconds]
<FromGitter> <bararchy> How come I don't see @gring talking about new Godot here? ;)
<FromGitter> <bararchy> oops @girng
ua has quit [Excess Flood]
ua has joined #crystal-lang
<FromGitter> <girng> @bararchy :)
ternarysolo has joined #crystal-lang
lesderid has joined #crystal-lang
bmcginty has quit [Ping timeout: 240 seconds]
<FromGitter> <bararchy> Any way to easly search if Array_A holds all the items, in the same order and Array_B? ⏎ ([1,2,3,4,5].has?([3,4,5]) => true)
<FromGitter> <mamantoha> @bararchy `[3,4,5].all? { |e| [1, 2, 3,4,5].includes?(e) }`
<FromGitter> <mamantoha> Or you can use `Set` - https://crystal-lang.org/api/0.27.2/Set.html#subset?(other:Set)-instance-method
<z64> both your example and Set are unordered, though. bararchy wants to check that `[3, 4, 5]` is a subset in the same order
<FromGitter> <bararchy> ^ yeha, was just testing that ang got to the same conclusion,
<FromGitter> <bararchy> those are unordered
<FromGitter> <bararchy> thanks though :) @mamantoha
<FromGitter> <j8r> Set is based on Hash, and Hash is orderd
<FromGitter> <straight-shoota> @j8r That's an implementation detail and only a coincidence. By definition, `Set` is unordered.
<FromGitter> <j8r> So that's in fact an `OrderedSet`
<FromGitter> <bararchy> @j8r this will be true => `[1,2,3,4,5,6,7].to_set.superset?([3,4,7].to_set)` though in my example I would like it to be false
<FromGitter> <kinxer> This is my first stab at this: https://carc.in/#/r/6hph
<FromGitter> <kinxer> `contains` is perhaps not the best naming, but I think the implementation is decent.
<FromGitter> <bararchy> Cool! @kinxer
<FromGitter> <kinxer> There might be a way to do it without creating so many new arrays, though.
<FromGitter> <straight-shoota> shorter: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ But still unnecessary allocations. [https://gitter.im/crystal-lang/crystal?at=5c8a5e2b25e4e24c076af0d2]
<FromGitter> <straight-shoota> needle = [3, 4, 5]
lucasb has joined #crystal-lang
duane has joined #crystal-lang
<FromGitter> <kinxer> I think this is more optimal: https://carc.in/#/r/6hq7
<FromGitter> <kinxer> And here it's a little simplified but less optimal: https://carc.in/#/r/6hq8
<FromGitter> <kinxer> I'm gonna work up a benchmark carc for these... One sec.
<FromGitter> <yxhuvud> `(needle - superset).empty?` is slightly cleaner, but will still allocate for the missing entries
<FromGitter> <kinxer> @straight-shoota https://carc.in/#/r/6hqb
<FromGitter> <kinxer> That may or may not be desired behavior.
<FromGitter> <kinxer> Actually, let me trim that down to make it more clear...
<FromGitter> <kinxer> https://carc.in/#/r/6hqc
FromGitter has quit [Remote host closed the connection]
ternarysolo has quit [Ping timeout: 250 seconds]
ternarysolo has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
bmcginty has joined #crystal-lang
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
duane has quit [Ping timeout: 245 seconds]
crystal-lang564 has quit [Ping timeout: 258 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
ternarysolo has quit [Ping timeout: 246 seconds]
ternarysolo has joined #crystal-lang
ternarysolo has quit [Ping timeout: 245 seconds]
oprypin has joined #crystal-lang
marmotini_ has joined #crystal-lang
marmotini_ has quit [Ping timeout: 250 seconds]
shmibs has quit [Quit: leaving =o]
shmibs has joined #crystal-lang
ashirase has joined #crystal-lang
ternarysolo has joined #crystal-lang