<FromGitter>
<yorci> what if i have a big structured data like tree, lets say i have an namedtuple inside of array inside of namedtuple inside of array and namedtuples have three or more keys and i want that data to assign on a variable, i must specify the type of all of them?
<FromGitter>
<aisrael> You should probably be using classes, or, type `alias`es at the very least?
<codenoid>
"TCP Socket" is "TCP Client", beginner like me will be mixed up about this,
rohitpaulk has joined #crystal-lang
<FromGitter>
<bew> Well what do you mean by "tcp client" if it's not a tcp socket ?
<FromGitter>
<yorci> @aisrael but how? i didnt really understand about it, im not type safe based language so its hard to understand for me
<FromGitter>
<yorci> there is any documentation about it ? i mean structure data
<codenoid>
"tcp socket" (which is mean tcp client) is not suitable for a layman like me
<FromGitter>
<bew> Did you read the language documentation?
<codenoid>
tcp client - tcp server, vs tcp socket vs tcp server, i'm very confused
<codenoid>
ok then
<FromGitter>
<bew> It basically explains how to create and use a class
faustinoaq has quit [Quit: IRC client terminated!]
faustinoaq has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
duane has quit [Ping timeout: 264 seconds]
duane has joined #crystal-lang
codenoid has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<codenoid>
hi, i have int with value 100, i want do something like `a = 0; 100.times.each { |i| # a => 99 * 98 * 97 ... 2 * 1 } ` but seems a variable doesn't change the value (still 0)
<hightower2>
codenoid 100.times { ... } without each
<hightower2>
(that's at least the first change you could make)
alex`` has joined #crystal-lang
<hightower2>
second is, the i is going to go from 0 to 99, so you'll keep multiplying a (zero) with something, which will be zero
<codenoid>
no, actually, `a = 0; (1...101).each {|i| a = i if i == 1; a = i * a if i > 1; }; puts a # => 0
<FromGitter>
<aisrael> what happens if you rename the `a = 0` to `b = 0`?
<FromGitter>
<bew> Just search tcpclient in the api docs
<FromGitter>
<bew> @yorci just ask your question(s) :)
<FromGitter>
<bew> @yorci NamedTuple are not really meant to be used in complex data structures, you should use structs of classes instead
alex``` has joined #crystal-lang
<hightower2>
codenoid you don't need a check if i is equal to 1 or greater, and especially not in two different ifs
<FromGitter>
<aisrael> Nah ok I get it. At first I thought it was a scope thing
codenoid has quit [Ping timeout: 240 seconds]
<FromGitter>
<aisrael> @codenoid What happens if you put a `puts a` before the closing curly brace?
hightower2 has quit [Read error: Connection reset by peer]
hightower2 has joined #crystal-lang
radagast_04 has joined #crystal-lang
radagast_04 has quit [Remote host closed the connection]
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter>
<straight-shoota> @j8r I don't think kamber qualifies as a static site generator, it's rather a server for static site content. It needs to be running to serve a website and it needs to be recompiled to apply changes in the template
<hightower2>
codenoid you seem to be generating too high integer value to fit into the variable. Reduce 1..100 to 1..10 and you'll see the values
<codenoid>
wut, :/
<codenoid>
hmmm
<hightower2>
you seem to be insisting on 'if' for value of i... If you really want that then at least have one if, like buf = i == 1 ? i : buf * i
<codenoid>
yeah, ternany much simple
<hightower2>
in fact, if you use "next if" then you don't need the second if because it's guaranteed
<codenoid>
yeah, `(1..10).each { |i| buf = i == 1 ? i : i * buf }`
<codenoid>
but i need to change 10 to 100
maattdd_ has quit [Ping timeout: 256 seconds]
<FromGitter>
<ezrast> @codenoid BTW, TCP socket vs client is a networking fundamentals thing. When a server accepts a connection, it spawns a new socket that is connected to the client's socket, and after that the client/server distinction is lost. Both sides now just have a socket as far as the TCP stack is concerned. There's no such thing as a client after the connection is established.
<FromGitter>
<ezrast> In Crystal, that means that `TCPServer#accept` yields a `TCPSocket` object to the server-side code. Calling it `TCPClient` wouldn't make sense there.
codenoid_ has joined #crystal-lang
<codenoid_>
ok, Socket,
codenoid has quit [Ping timeout: 268 seconds]
<FromGitter>
<codenoid> so i can't just change Int32 to Int64 right ?
<FromGitter>
<ezrast> It won't help because 100! is still much larger than `Int64::MAX`
<FromGitter>
<codenoid> 😟
<codenoid_>
lol, it's actually will be used as String
<codenoid_>
nvm,
codenoid_ has quit [Quit: i sleep in my keyboard]
hightower2 has quit [Ping timeout: 264 seconds]
rohitpaulk has quit [Ping timeout: 256 seconds]
<FromGitter>
<hfabre> Hi guys. Anyone could tell me where this error comes from ? ```Error in src/crplat-qt.cr:1: while requiring "prelude": can't find file 'prelude' relative to '/home/hfabre/local/projects/crplat-qt/src'```
<FromGitter>
<hfabre> I got it in an almost empty project with crystal 0.24.1 qt5 shard
<FromGitter>
<hfabre> (Here is the line in src/crplat-qt.cr:1 `require "./crplat-qt/*"`)
<FromGitter>
<straight-shoota> @hfabre looks like your crystal path is messed up
<FromGitter>
<straight-shoota> what does `crystal env` show?
<FromGitter>
<hfabre> Hmm same after reinstalling, it looks like a crenv/crystal-build issue doesn't it ?
<FromGitter>
<hfabre> anyway I'm going to see if I can solve this, thanks for pointing me in the right direction !
<FromGitter>
<straight-shoota> good look
<FromGitter>
<straight-shoota> I've never used crenv and I don't know why I would need it
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
sz0 has joined #crystal-lang
Papierkorb has left #crystal-lang ["Konversation terminated!"]
bijan_ has joined #crystal-lang
duane has quit [Ping timeout: 256 seconds]
alex`` has quit [Quit: WeeChat 2.0.1]
alex`` has joined #crystal-lang
<FromGitter>
<hfabre> Ruby habits but it may not be that important to be able to manage multiple crystal version on the same machine. Thanks @straight-shoota :)
<FromGitter>
<straight-shoota> at least not currently. should always use the latest one.
hightower2 has joined #crystal-lang
bijan_ has quit [Quit: System has gone to sleep. ZZZzzz…]
<FromGitter>
<hfabre> 👍
alex`` has quit [Ping timeout: 256 seconds]
alex``` has quit [Ping timeout: 260 seconds]
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]