## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• 10:40
straight-shoota closed #13040
• 10:37
straight-shoota milestoned #12963
• 10:34
straight-shoota milestoned #13034
• 10:34
straight-shoota milestoned #13034
• 00:58
HertzDevil synchronize #13034
• 00:47
HertzDevil synchronize #13034
• Feb 02 22:23
• Feb 02 22:22
straight-shoota closed #13039
• Feb 02 22:21
straight-shoota closed #13020
• Feb 02 22:21
straight-shoota closed #11646
• Feb 02 22:21
HertzDevil synchronize #13034
• Feb 02 19:26
straight-shoota labeled #13044
• Feb 02 19:26
straight-shoota labeled #13044
• Feb 02 19:26
straight-shoota assigned #13044
• Feb 02 19:26
straight-shoota opened #13044
• Feb 02 18:56
straight-shoota synchronize #13043
• Feb 02 18:55
straight-shoota labeled #13043
• Feb 02 18:55
straight-shoota labeled #13043
• Feb 02 18:55
straight-shoota labeled #13043
• Feb 02 18:55
straight-shoota labeled #13043
Daniel Worrall
@Daniel-Worrall
Oh, glossed over. lazy was already mentioned
mfiano
@mjfiano:matrix.org
[m]
Makes sense, thanks all
Does crystal have anything like...I'm not sure what it's called, but in Nim, you can assign a slice to a slice of a variable...like:
var x = [1, 2, 3, 4, 5]
var y = [6, 7, 8, 9, 10]

x[1..2] = y[1..2] # x => [1, 7, 8, 4, 5]
Ary Borenszweig
@asterite
If you remove var from that code, it already works in Crystal. It's nothing special in the language, just a method call
mfiano
@mjfiano:matrix.org
[m]
Oh nice. It seems you can even grow shrink it with unsymmetrical ranges
Thanks @asterite
mfiano
@mjfiano:matrix.org
[m]
Are there functions for extracting the sign and fractional components of floating-point numbers? In some languages you have something like sign and fract:
sign(42.0) # 1.0
sign (-42.0) # -1.0
sign (0.0) # 0.0
fract(42.123) # 0.123
I suppose line 3 can be implemented differently if there is a distinction between IEEE-754 positive and negative zero
George Dietrich
@Blacksmoke16
last one could just be like value - (value.floor) probably?
mfiano
@mjfiano:matrix.org
[m]
Of course I only went down the type tower API from Float64 to Float
George Dietrich
@Blacksmoke16
inherited methods are also listed towards the bottom
mfiano
@mjfiano:matrix.org
[m]
I suppose I was searching for the wrong half, fract ðŸ˜†
mfiano
@mjfiano:matrix.org
[m]
If I have a type with value types (floats) for ivars, is it conventional to call a method which copies it clone or dup? In this case there is nothing to traverse for a deep copy, but I see some projects use clone in this case, while others use dup, so I'm not sure if there is a consensus.
George Dietrich
@Blacksmoke16
i imagine dup would be ok if the only thing you need is a new type instance
Ary Borenszweig
@asterite
dup for shallow copy, clone for deep copy
mfiano
@mjfiano:matrix.org
[m]
Yes, in this case a deep copy is a shallow copy
Maybe I worded it poorly. I was stating that either would be semantically correct for this particular example, and asking if there was a general agreement of which takes preference.
Ary Borenszweig
@asterite
I think there's no need to implement clone in this case given that dup already covers that use case
mfiano
@mjfiano:matrix.org
[m]
Thanks
Taupiqueur
@alexherbo2
how to convert the following yaml { a: ["1", "2"], b: true } to a MyClass with items being ItemA, ItemB?
the real use case is to parse a scope.yml having the properties roots, paths, etc. in a Scope class, I'd like to avoid flow control to check the filters as scope.roots, scope.paths, to something like scope.filters having their own class
Taupiqueur
@alexherbo2
I have Scope with property roots and property paths to pull the data from the file, but what I want when creating the instance is more something like a property filters doing when having roots keys, Root.new(value), etc.
so when filtering, I can just do scope.filters.all? { |filter| filter.evaluate_with(path) }
Taupiqueur
@alexherbo2
not sure if I actually need an intermediate class to pull the data fromscope.ymlother than Scope
like ScopeFile and using it to create the new Scope with the correct filters
George Dietrich
@Blacksmoke16
regarding your first question you can use a custom converter on that property
that could do like Item.new pull.read_string and return that array
Taupiqueur
@alexherbo2
currently I have a monolithic Scope class with hard-coded properties, it is not necessarily a problem as my scope will probably not have other props than roots, paths, extensions, but I realized there was too much logic in my Scope#evaluate method
I have to re-check if the props are nil, what they are supposed to do etc.
mfiano
@mjfiano:matrix.org
[m]
Is there a builtin module with a linear interpolation function?
George Dietrich
@Blacksmoke16
if its not in Math id vote no
@RespiteSage
I just realized I basically accidentally reimplemented the main part of Tracery in my discord bot.
Daniel Worrall
@Daniel-Worrall
Hey @RespiteSage just to let you know, discordcr was moved to shardlab/discordcr and has updates there
Just saw that you were using the old source in your dependencies
@RespiteSage
I'll fix the dependency URI.
mfiano
@mjfiano:matrix.org
[m]
Am I correct to assume that all optional parameters are also named? That is, there is no such thing as optional positional parameters in this language like I am used to? ðŸ˜†
George Dietrich
@Blacksmoke16
no there deff is?
mfiano
@mjfiano:matrix.org
[m]
Can you give me an example? I've been reading the docs for a few minutes...
George Dietrich
@Blacksmoke16
would just be a var with a default value
mfiano
@mjfiano:matrix.org
[m]
Right. But that can also be invoked with a name, so satisfies the assumption above that all optional parameters are also named?
George Dietrich
@Blacksmoke16
all arguments can also be provided via their name
mfiano
@mjfiano:matrix.org
[m]
Gotcha
George Dietrich
@Blacksmoke16