<FromGitter>
<Daniel-Worrall> nvm, it's on the crystal install page
<FromGitter>
<Blacksmoke16> think you only need it for the playground
<FromGitter>
<Daniel-Worrall> eh, you'd think, but no
<FromGitter>
<Daniel-Worrall> it's complaining I need it for running a websocket
<FromGitter>
<Blacksmoke16> playground uses websockets so maybe thats it
<FromGitter>
<Daniel-Worrall> oh, and I needed pkg-config :thinking:
<FromGitter>
<Daniel-Worrall> new installs are weird when you don't pull from the package manager
<FromGitter>
<ImAHopelessDev_gitlab> damnit just got hooked on the world series, back to coding!!
<FromGitter>
<ImAHopelessDev_gitlab> there goes 2 hours, fack
duane has quit [Ping timeout: 265 seconds]
hightower3 has quit [Ping timeout: 264 seconds]
alex``` has quit [Ping timeout: 268 seconds]
teardown has joined #crystal-lang
<FromGitter>
<christopherzimmerman> @ImAHopelessDev_gitlab what a disappointing game
<FromGitter>
<Daniel-Worrall> Nested JSON is fked which slows down the progress on one of my apps :/
<FromGitter>
<Daniel-Worrall> also, accidental Ctrl+Enter's suck. Submitted the issue without even formatting it properly :^)
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 240 seconds]
<FromGitter>
<watzon> Really wishing Crystal had an async/await type situation
<FromGitter>
<Daniel-Worrall> There are shards looking to assist in that
<FromGitter>
<watzon> Yeah which is nice, but there's nothing like having it as an actual language feature
teardown has quit [Ping timeout: 265 seconds]
teardown has joined #crystal-lang
absolutejam2 has joined #crystal-lang
DTZUZO has quit [Ping timeout: 265 seconds]
ht_ has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 264 seconds]
DTZUZU has quit [Ping timeout: 240 seconds]
ht_ has quit [Remote host closed the connection]
DTZUZU has joined #crystal-lang
absolutejam2 has joined #crystal-lang
dwdv has joined #crystal-lang
<FromGitter>
<gdotdesign> I'm working on Crystal and Ruby projects simultaneously and right now on the Ruby one and was editing a file and I was thinking "Why is this nor formatting automatically? Is there an error somewhere?" π
<FromGitter>
<bararchy> I got you ^
<FromGitter>
<bararchy> hahahah
<FromGitter>
<bararchy> I'm also used to the formatter telling me if I broke something XD
<FromGitter>
<gdotdesign> :D right?
dwdv_ has joined #crystal-lang
dwdv has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 265 seconds]
absolutejam2 has quit [Ping timeout: 268 seconds]
<FromGitter>
<ImAHopelessDev_gitlab> @watzon similar to JS's await? Where you can basically call them one after another and they perform asynchronously?
<FromGitter>
<ImAHopelessDev_gitlab> without having to do method chaining/callback hell?
<FromGitter>
<watzon> Yeah JS, Rust, Python, Dart, and plenty of other languages have something like that built in
<FromGitter>
<ImAHopelessDev_gitlab> there was a twitter thread discussing this on asterite's page. i remember seeing something about it a few weeks ago. can't find it atm though
FromGitter has quit [Read error: Connection reset by peer]
FromGitter has joined #crystal-lang
<FromGitter>
<asterite> for those wanting async/await, a must read:
FromGitter has quit [Read error: Connection reset by peer]
FromGitter has joined #crystal-lang
<FromGitter>
<ilanpillemer> There is also as good talk by the Kotlin guy on this when he shows Kotlin's co routines.
alex``` has joined #crystal-lang
<FromGitter>
<ilanpillemer> And Rob Pike's examples of patterns using channels and co routines also is pretty good, especially as so many of his examples include gophers burnjnf
<FromGitter>
<ilanpillemer> Project Loom is also interesting
<FromGitter>
<ilanpillemer> But the Kotlin's guy talk is great to did deep into the horrors of async await.
<FromGitter>
<ImAHopelessDev_gitlab> i have no idea what's going on, but i'd like to watch gophers burn some c++ manuals
<FromGitter>
<yxhuvud> Personally I'd much rather see a development towards structured concurrency than towards async/await. It perhaps forces slightly more thought on the user, but it also gives a lot more control. And the problem area in itself has nasty enough issues that perhaps that kind of thought is more helpful than not.
<FromGitter>
<ImAHopelessDev_gitlab> i'd also like to see some JS books being burned as well. however, I don't think I'd be able to watch it. I use JS extensively for the front-end. I like JS, but the developer should always try to ascend.
<FromGitter>
<ilanpillemer> Thougu Kotlin also has the colour problem.
<blassin>
what's the "best" online index for browsing shards?
<FromGitter>
<Blacksmoke16> but in this case wouldnt `0` work in . both cases?
<FromGitter>
<tenebrousedge> I'd just do a hash block
<FromGitter>
<tenebrousedge> well, if possible
duane has quit [Ping timeout: 240 seconds]
HumanG33k has joined #crystal-lang
duane has joined #crystal-lang
<FromGitter>
<ImAHopelessDev_gitlab> good morning
<FromGitter>
<ImAHopelessDev_gitlab> a phenomena is happening but i don't know what it's called
<FromGitter>
<bararchy> Winter
<FromGitter>
<bararchy> it's called Winter
<FromGitter>
<ImAHopelessDev_gitlab> hehe
<FromGitter>
<ImAHopelessDev_gitlab> for example, last few days i've been coding non-stop. then, today, when i take a look back at my code, i don't really understand what it's doing i have to "refresh" my brain after looking at it. but i just coded it like less than 48 hours ago...
<FromGitter>
<ImAHopelessDev_gitlab> why is this happening and what is it called. most importantly, is it bad?
<FromGitter>
<tenebrousedge> it's called, "working on a large program"
<FromGitter>
<bararchy> it's normal
<FromGitter>
<bararchy> it's called "context wsitching"
<FromGitter>
<ImAHopelessDev_gitlab> @tenebrousedge you can relate, right?
<FromGitter>
<bararchy> it's hard to keep "in memory" all the things you're doing for long, so you need to "reboot" the ata
<erdnaxeli>
the blog post posted earlier today about async/await was really interesting, thanks asterite
<erdnaxeli>
(the conclusion is: you don't want async/await :p)
<FromGitter>
<ImAHopelessDev_gitlab> i just feel like something is wrong, because i code away and away, then move on to the next thing. then come back and my brain is like: O_O WTF
<FromGitter>
<tenebrousedge> there's a limit to how much code you can keep in memory. Two days is a little short unless you're working with lots of different parts of a large codebase
<FromGitter>
<tenebrousedge> but there's a related issue which you may have encountered, where you have a bug, and at the moment you get done solving it you no longer understand how it works
<FromGitter>
<ImAHopelessDev_gitlab> so basically, my brain has some stack memory that overflows every few days?
<FromGitter>
<tenebrousedge> "Yay, all the tests pass! Wait, what does this do, again?"
<FromGitter>
<ImAHopelessDev_gitlab> ROFL!!!
<FromGitter>
<ImAHopelessDev_gitlab> YES
<FromGitter>
<tenebrousedge> the really embarrassing one is where you're working on a team, and you find some really stupid code, and you start swearing under your breath. "What moron wrote this?" `git blame` --> you.
<FromGitter>
<ImAHopelessDev_gitlab> @tenebrousedge @bararchy well, i feel a lot better now, knowing at least it's a thing and other devs experience/ know about it. appreciate the support, kudos π
duane has quit [Ping timeout: 240 seconds]
duane has joined #crystal-lang
<FromGitter>
<gdotdesign> looking back at code that I wrote 2 or even 1 year ago is like "WTF is this?" π
<FromGitter>
<bararchy> Sometimes even a month ago is like "pfffff look what I learned now past me!"
absolutejam2 has joined #crystal-lang
<FromGitter>
<repromancer_gitlab> @ImAHopelessDev_gitlab Even though I really don't enjoy his sense of humor or presentation style, I think Robert C. Martin's recommendations in Clean Code (the book or video course) go a long way toward avoiding those sort of code clarity problems.
<FromGitter>
<naqvis> @Blacksmoke16 Thanks for putting together awesome-crystal naughty list, quick question on *CI but last build was more than 30 days ago*, build is triggered on commit, what if there is no change in code-base? so do you still believe such metric worth evaluating?
<FromGitter>
<repromancer_gitlab> It's mostly a bunch of advice on naming and organizing things in a way that is "self-documenting", and I don't agree with everything he says, but I don't know a better book in that vein off the top of my head.
<FromGitter>
<repromancer_gitlab> (I haven't read it yet, but I imagine Scott Wlaschin's free "F Sharp for Fun and Profit" blog/book covers a lot of the same ground)
<FromGitter>
<absolutejam_gitlab> > i just feel like something is wrong, because i code away and away, then move on to the next thing. then go back to look at older code and my brain is like: O_o WTF β β It could be that you're hacking away and not thinking about the bigger picture too
<FromGitter>
<absolutejam_gitlab> it's easy to go down a rabbit hole without actually planning out how your components will interact, what your API should look like, etc.
<FromGitter>
<tenebrousedge> experience is what teaches you to recognize a mistake when you make it again
<FromGitter>
<asterite> T.zero
ht__ has joined #crystal-lang
<FromGitter>
<tenebrousedge> ?
<FromGitter>
<asterite> for what bararchy needed before, 0 for Int32, 0.0 for Float64
<FromGitter>
<repromancer_gitlab> Big pluses include actually-well-thought-out threading, full search history (standard plan is free for OSS projects), and actual Markdown support (vs. Slack's pseudo-markdown)
<FromGitter>
<repromancer_gitlab> not to mention two-way Matrix support
<FromGitter>
<asterite> nice
<FromGitter>
<asterite> If someone wants to go for it, please open a discussion in the forums (I can π but I'm not in charge of infrastructure, though I'd love a more structured way to chat in real time related to Crystal)
<FromGitter>
<kinxer> @repromancer_gitlab This looks fantastic.
<FromGitter>
<kinxer> @ImAHopelessDev_gitlab What are the black lines?
<FromGitter>
<ImAHopelessDev_gitlab> Potential ideas (abstract), then, once created they are linked with green lines
<FromGitter>
<ImAHopelessDev_gitlab> If that makes sense lol
<FromGitter>
<kinxer> Gotcha.
<FromGitter>
<ImAHopelessDev_gitlab> I want to see others and how they visualize
<FromGitter>
<ohenepee> Hello... Can someone pls help me with this... Newbie here
<FromGitter>
<ohenepee> ``````
<FromGitter>
<ohenepee> Oops.. What's with using gitter on mobile?
<FromGitter>
<Blacksmoke16> its not great
<FromGitter>
<kinxer> @ImAHopelessDev_gitlab That's probably pretty close to how I start. I'd have to think longer about how that (hopefully and usually) turns into something a little more neatly structured.
<FromGitter>
<kinxer> @Blacksmoke16 Does carc.in work fine on mobile?
<FromGitter>
<ImAHopelessDev_gitlab> @kinxer Is that when OOP comes in, or can it be done without it?
<FromGitter>
<Blacksmoke16> it should
<FromGitter>
<ohenepee> Say I have an array of Int32, and I'm iterating over it, how do I check if a number exists in it?
<FromGitter>
<kinxer> @ohenepee If you're trying to show code that you have (and it's not too long), you could probably use https://carc.in/#/cr or https://play.crystal-lang.org/#/cr. (Though I don't think this question necessarily requires that.)
<FromGitter>
<ImAHopelessDev_gitlab> @kinxer what's interesting is, I love objects. I view everything as an object. Same when I was coding in js (with nodejs)
<FromGitter>
<ohenepee> @Blacksmoke16 yh I'm using that, but adding `&& array.index(item) < 5` gives me an undefined method error
<FromGitter>
<ohenepee> The error is for fh
<FromGitter>
<ohenepee> The
<FromGitter>
<ohenepee> The error is for the < sign
<FromGitter>
<kinxer> @ImAHopelessDev_gitlab I think there are, rarely, times when you don't need any classes (or structs or whatever), but generally my initial, messy though process does include objects. I think that may be a result of my education.
<FromGitter>
<ImAHopelessDev_gitlab> I'm gonna make a topic about this, I think it's very interesting and want to see other developers` opinions/visualizations
<FromGitter>
<kinxer> They're also not necessarily the *right* objects yet.
<FromGitter>
<repromancer_gitlab> @ImAHopelessDev_gitlab @kinxer My personal projects usually go like this: I sketch out my program with high-level dummy classes/methods until I encounter the need for a bikeshed (http://bikeshed.com/). I then google around for pre-fabricated sheds, and decide they are too bloated for my needs. I then contemplate the Platonic ideal of the minimum necessary shed, and this becomes its own project. Then,
<FromGitter>
... it's Monday.
<FromGitter>
<tenebrousedge> no
<FromGitter>
<Blacksmoke16> but what is the higher level objective of what you're trying to do? as there might be a better way to go about it
<FromGitter>
<tenebrousedge> do not take more than `n` elements of the array if you only care about the first `n` elements
<FromGitter>
<tenebrousedge> `index` will scan the whole thing
<FromGitter>
<Blacksmoke16> index stops when it finds the value
<FromGitter>
<ImAHopelessDev_gitlab> i love me some tuples
<FromGitter>
<ohenepee> @Blacksmoke16 How do I check the index of the number I'm looking for in a tuple?
<FromGitter>
<ohenepee> Cos I don't see index in the tuple doc
<FromGitter>
<Blacksmoke16> tuple includes `Indexable` which defines it
<FromGitter>
<Blacksmoke16> which is how it gets defined on array as well
<FromGitter>
<ohenepee> Yep found it, thanks
<FromGitter>
<ohenepee> But how exactly is this better than the array approach, in relation to making sure the item exists?
<FromGitter>
<Blacksmoke16> was the array of values a constant, or just like `[1,2,3,4,...]`?
<FromGitter>
<Blacksmoke16> a tuple would be faster than an array, assuming the array was not a const
<FromGitter>
<ohenepee> Okay, I forgot to mention that I'm picking the array from a larger container array... Hence it'll be a lot of work to rewrite the whole file as tuples instead of arrays
<FromGitter>
<Blacksmoke16> ah fair enough
<FromGitter>
<ohenepee> Thanks for ur help @Blacksmoke16 @tenebrousedge
<FromGitter>
<kinxer> So it looks like (for this particular problem), using the iterator (which is returned by `Array#each()`) is always slower than creating a new array, but creating a new array does (of course) have a memory cost.
<FromGitter>
<tenebrousedge> I would only choose `each.first` if I had profiled the entire codebase and identified that the use of `first` was a bottleneck and `each.first` fixed it
<FromGitter>
<tenebrousedge> micro-benchmarks have little practical value
<FromGitter>
<kinxer> I had just expected `each.first` to be faster because it wasn't copying array elements.
<FromGitter>
<tenebrousedge> can you explain your thinking there in more detail?
<FromGitter>
<kinxer> `Array#first(n)` creates a new array and copies the first `n` values (or references) from the original array into the new array. I'd have expected this memory operation to be slower than allocating an `Iterator` and then performing certain operations with it.
<FromGitter>
<tenebrousedge> hmm. What if `n` is large?
<FromGitter>
<ohenepee> `Hash(Int32, Hash(Int32, Hash(Int32, Hash(Int32, Array(String)))))` is the hash I'm to store complex data, the compiler claims it has an undefined method `each_key` for `Tuple(Int32, Hash(Int32, Hash(Int32, Hash(Int32, Array(String)))))`
<FromGitter>
<kinxer> That's when I'd expect the `Iterator` to be faster, since I would expect the "check index, get value, check value" sequence in the `Iterator` to take less time than allocating a new array and then doing a "get next value, check value" loop.
<FromGitter>
<ohenepee> Is there a problem or limit with deeply-nested hashes?
<FromGitter>
<tenebrousedge> @ohenepee can you use some aliases there?
<FromGitter>
<tenebrousedge> some semantically meaningful labels there are probably good for both bugfinding and legibility
<FromGitter>
<kinxer> @ohenepee Is there a benefit to nested hashes instead of `Hash(Tuple(Int32, Int32, Int32, Int32), Array(String)`?
<FromGitter>
<Blacksmoke16> hashes aren't super great for not simple things, might be better off using objects
<FromGitter>
<kinxer> Also, that looks like you're trying to call `each_key` on a `Hash` entry rather than a `Hash`. Did you do something like `hash.each { |value| value.each_key}`?
<FromGitter>
<ohenepee> @kinxer the nesting follows the idea or structure I'm building, so I prolly can't use ur option
<FromGitter>
<ohenepee> @kinxer Yes I did
<FromGitter>
<kinxer> Echoing what @Blacksmoke16 says, this looks like a job for some kind of tree.
<FromGitter>
<kinxer> `Hash#each` yields a `(key, value)` to the block, so you want `hash.each { |(_, value)| value.each_key}`
<FromGitter>
<kinxer> Using the parentheses in the block argument to unpack the tuple.
<FromGitter>
<ohenepee> @kinxer Thanks, that fixed it... I'm actually rewriting something I wrote in NodeJS... Crystal is too sweet
<FromGitter>
<tenebrousedge> @ohenepee `Hash#dig` might be useful for you
<FromGitter>
<ohenepee> Checking it out
<FromGitter>
<ohenepee> Yep... That's something I definitely need... Thanks @tenebrousedge
duane has joined #crystal-lang
absolutejam2 has joined #crystal-lang
sagax has joined #crystal-lang
<FromGitter>
<hugopl> guys, I just wrote a stupid macro that could be useful for someone, https://github.com/hugopl/version.cr it just get the version number from the shard.yml and create a VERSION constant with it.
<FromGitter>
<kinxer> @hugopl That looks useful. Thanks for sharing!
<FromGitter>
<hugopl> thanks
teardown has quit [Ping timeout: 240 seconds]
<FromGitter>
<ImAHopelessDev_gitlab> gosh i love crystal
<FromGitter>
<ImAHopelessDev_gitlab> Finishing up selling items to npc, next is trading which will be fun
<FromGitter>
<ImAHopelessDev_gitlab> crystal makes it easy, though. so i should be fine, kinda been on a roll ever since i moved to notepad
teardown has joined #crystal-lang
<FromGitter>
<kinxer> Trading between players?
<FromGitter>
<ImAHopelessDev_gitlab> yeah
<FromGitter>
<kinxer> Cool. Do you already have it implemented on the client-side in Godot?
<FromGitter>
<kinxer> Or will you do that after you work out the server-side?
<FromGitter>
<ImAHopelessDev_gitlab> yeah, implemented on the client with Godot, now just server-side
<FromGitter>
<ImAHopelessDev_gitlab> which is the fun part tbh, i like crystal more than gdscript. however, both are really nice.
<FromGitter>
<ImAHopelessDev_gitlab> that's how i created my passive tree. implemented it first on client (godot's ui system). then in crystal, secure it so a player can only allocate if they have dependent nodes, etc.
<FromGitter>
<kinxer> Passive skills?
<FromGitter>
<ImAHopelessDev_gitlab> yeah, like 5% increase health,e tc
<FromGitter>
<kinxer> So you have totally different passive and active trees?
<FromGitter>
<ImAHopelessDev_gitlab> yeah, active skills are gems where you slot into gear
<FromGitter>
<ImAHopelessDev_gitlab> that's all done server-side as well in crystal, which is nice
<FromGitter>
<kinxer> Oh, interesting. Do you have a class system of some kind, or is character customization just a combination of passives and gems?
<FromGitter>
<ImAHopelessDev_gitlab> example, power slam skill, and increase area of effect gem. i extract them from the gear slots in crystal, then notify the client they have that skill now, with the supported gem
<FromGitter>
<ImAHopelessDev_gitlab> just combination of passives and gems for now haha
<FromGitter>
<kinxer> Cool. Sounds like you're making quite a lot of progress.
<FromGitter>
<ImAHopelessDev_gitlab> yeah, i will need to stop at some point cause this is becoming too much. but honestly, the way i structured everything, it's pretty organized. i can get to whatever method i need instantly.
<FromGitter>
<ImAHopelessDev_gitlab> however, that's prob just because i'm the only one working on this lol.
<FromGitter>
<kinxer> Are you planning on releasing the game at some point?
<FromGitter>
<kinxer> That is, as opposed to it just being a hobby project.
<FromGitter>
<ImAHopelessDev_gitlab> yeah def planning on releasing it. i got a site ready. custom forum with a guild system, forum gold, ability to buy in-game microtransactions (working with paypal), and much more. just need to finish all this back end stuff (master and game server w/ crystal)
<FromGitter>
<kinxer> Yeah, it sounds like you do really have everything set up. How are you planning on hosting servers?
<FromGitter>
<ImAHopelessDev_gitlab> well, i've been thinking about a dedicated for the master server, and then VPSs for the game instance servers to horizontally scale. i've got this all setup have been testing it but only with VPSs, β β it works nice because I can add a Europe realm. Buy a vps or dedi located in Europe, run my installer script && upload server files and it auto connects to the master server (loop do), then
<FromGitter>
... once it authenticates itself, it's ready to create game instances. β β However, I'm only go to start with a few realms UsWest, UsEast, Brazil and see how it pans out. There would definitely have to be an alpha so I can test it at scale. I've only tested it with so many players (300 to 900) i think my last benchmark was. Th ... [https://gitter.im/crystal-lang/crystal?at=5db754b9a3f0b17849a69da8]
<FromGitter>
<kinxer> Is your master server written in Crystal as well?
<FromGitter>
<tenebrousedge> look into Traefik (https://traefik.io/) for routing
<FromGitter>
<ImAHopelessDev_gitlab> Yeah!!
<FromGitter>
<kinxer> So you actually have two (or three?) different Crystal servers that you've written?
<FromGitter>
<ImAHopelessDev_gitlab> Master Server basically handles authentication (login), chat lobby, character listing, switching channels, browsing games, editing player profile, whispering, add/remove friends/block, create char, delete char, etc (all i can think of off the top of my head)
<FromGitter>
<ImAHopelessDev_gitlab> @kinxer yeah two, master and game server. although, i was creating an auction house daemon thingi, but stopped because i don't know if i want to add an auction house yet lol
<FromGitter>
<kinxer> Interesting.
<FromGitter>
<kinxer> Honestly, you're a lot further than I thought you were. That's cool, though. You might end up having the first game in-production that's backed by Crystal.
<FromGitter>
<ImAHopelessDev_gitlab> I really miss the old social aspect of games, that's why I really like the lobby. All the characters appear at the bottom with the player's gear (armor, boots, helmet, sword, and shield so far).
<FromGitter>
<kinxer> Are game servers supposed to be long-lived (closer to an MMO instance) or short-lived (like a game of Gauntlet)? Or something in-between?
<FromGitter>
<kinxer> The community aspect is also interesting. I've been reading a bit recently about how game features relate to the social experiences of players.
<FromGitter>
<kinxer> @tenebrousedge That looks interesting. Thanks for sharing.
<FromGitter>
<ImAHopelessDev_gitlab> probably something in-between. there is a limit of how many games a player can create per minute. however, the zones inside the game (levels), don't get populated with monsters, crates, entities, etc until a a player enters. the games will cease when the last player leaves. or, i might add a soft delete after 60 seconds of no players joining it. this way, players can transfer items to a new
<FromGitter>
... account. or, if they need to leave and come back with a different character.
<FromGitter>
<ImAHopelessDev_gitlab> for example, items left on the floor will auto delete after 10 minutes
<FromGitter>
<ImAHopelessDev_gitlab> i also had to add a limit on the amount of times that can be dropped in a zone.. cause a player coulddrop like so many, then another player joins and rip my bandwidth and cpu usage lmao
<FromGitter>
<tenebrousedge> can you defer loading of those? Have "There are `x` items on the ground. Look at them?"
<FromGitter>
<ImAHopelessDev_gitlab> I have a nice honey bucket flood system in place too, every game function has its own internal rate limiting. which helps a lot, especially for not spamming people with messages (although, they cna just block you). but not spamming lobby chat rooms, etc is nice.
<FromGitter>
<ImAHopelessDev_gitlab> @tenebrousedge possibly, good idea
<FromGitter>
<tenebrousedge> or if it's a mouse-driven game, you could display a generic bag of loot, and load the contents on hover
<FromGitter>
<ImAHopelessDev_gitlab> actually pretty good idea, could be called bag of xxx or w/e, player can right click it to receive items or w/e
<FromGitter>
<tenebrousedge> :plus1:
<FromGitter>
<kinxer> Or you could even cause adverse conditions from having too much stuff on the ground (ground sucks up stuff or some creature(s) come to take it or something). Probably the treasure bag idea is better, though.
<FromGitter>
<ImAHopelessDev_gitlab> > Honestly, you're a lot further than I thought you were. That's cool, though. β π :)
Flipez has quit [Read error: Connection reset by peer]
Flipez has joined #crystal-lang
ht__ has quit [Remote host closed the connection]
<FromGitter>
<Daniel-Worrall> Does anyone foresee Crystal usable in the phone app market in the future?
<FromGitter>
<Daniel-Worrall> maybe something like rubymotion
<FromGitter>
<tenebrousedge> > FUTURE, *n*. That period of time in which our affairs prosper, our friends are true and our happiness is assured.
hightower2 has joined #crystal-lang
<hightower2>
Hey a simple one, how can I do array[10] = "x" if index 10 is currently not yet valid/existing?
<FromGitter>
<tenebrousedge> do indexes 0..9 exist?
<hightower2>
no
<FromGitter>
<tenebrousedge> then you probably need a hash and not an array
<hightower2>
The function populates the array in non-sequential order
<hightower2>
in the end all indices will exist
<hightower2>
but the method which fills them doesn't fill them sequentially
<hightower2>
(and the index is significant, it's not just about pushing elements to the array)
<FromGitter>
<tenebrousedge> then create an array of empty strings (or whatever your data type is) that's the size you need and use `array#map`
<FromGitter>
<tenebrousedge> mmm, or I guess if it's not sequential, then maybe use the array as the memo object in a `reduce` loop
<FromGitter>
<tenebrousedge> @Blacksmoke16 why should `insert` behave that way?
<FromGitter>
<Blacksmoke16> idk, just as a way to handle that use case while not breaking the more use `[idx] = `
<FromGitter>
<Blacksmoke16> just a thought i had
<FromGitter>
<tenebrousedge> hmm. Kay
<FromGitter>
<tenebrousedge> and `insert` mutates normally
<FromGitter>
<Blacksmoke16> mainly it would kind of make sense
<FromGitter>
<Blacksmoke16> if you insert and there is already a value it gets shifted
<FromGitter>
<Blacksmoke16> if you insert and index is higher than size then just drop it at the end
<FromGitter>
<Blacksmoke16> hightower2: use case would work as then as long as each key is inserted with the index it should be at, it would eventually be correct
<FromGitter>
<Blacksmoke16> also made me think that it would be nice if some type restrictions were added to array
<FromGitter>
<Blacksmoke16> like `self` if it mutates the current array, or `Array(T)` if it returns a new one
<FromGitter>
<tenebrousedge> uhh, what?
<FromGitter>
<tenebrousedge> shouldn't the type restrictions exist when the array is created/
<FromGitter>
<Blacksmoke16> i mean if you do like `arr.push(17)` that method should be like `def push(val) : self`
<FromGitter>
<Blacksmoke16> but `arr.shuffle` would be like `def shuffle : Array(T)`
<FromGitter>
<Blacksmoke16> since it returns a new array
<FromGitter>
<tenebrousedge> doesn't Crystal core omit those type restrictions?
<FromGitter>
<Blacksmoke16> omit them how?
<FromGitter>
<tenebrousedge> by not including them?
<FromGitter>
<Blacksmoke16> right, they're not included atm
<FromGitter>
<Blacksmoke16> but wouldn't hurt to have them?
<FromGitter>
<tenebrousedge> so far, I prefer to avoid explicit typing to whatever degree possible
<FromGitter>
<Blacksmoke16> im the opposite, don't omit return types if there is no need to
<FromGitter>
<Blacksmoke16> makes docs better, makes catching bugs easier. if in the future you have to remove it thats fine, but until then why not include it
<FromGitter>
<Blacksmoke16> kinda makes me wish you could specify the return type for docs without actually doing it
<FromGitter>
<Blacksmoke16> `# RETURNS: Int32`
<FromGitter>
<tenebrousedge> now that I'm okay with
<FromGitter>
<tenebrousedge> but I'm coming from Ruby and JS, and I'm a lazy typist