Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 16:20
    HertzDevil unlabeled #13013
  • 14:24
    renovate[bot] edited #12735
  • 14:22
    straight-shoota milestoned #13048
  • 14:22
    straight-shoota milestoned #13048
  • 13:24
    HertzDevil labeled #13048
  • 13:24
    HertzDevil labeled #13048
  • 13:24
    HertzDevil labeled #13048
  • 13:24
    HertzDevil opened #13048
  • 12:32
    straight-shoota closed #12924
  • 12:32
    straight-shoota closed #12921
  • 12:31
    straight-shoota closed #12983
  • 12:24
    straight-shoota closed #13045
  • Feb 05 15:55
    Blacksmoke16 closed #13047
  • Feb 05 15:53
    serge-hulne closed #13047
  • Feb 05 15:45
    Blacksmoke16 edited #13047
  • Feb 05 15:42
    serge-hulne labeled #13047
  • Feb 05 15:42
    serge-hulne opened #13047
  • Feb 05 02:16
    renovate[bot] edited #12735
  • Feb 04 23:27
    straight-shoota milestoned #12966
  • Feb 04 23:27
    straight-shoota milestoned #12966
From IRC (bridge bot)
@FromIRC
<postmodern> just noticed that String lacks in-place modification methods
George Dietrich
@Blacksmoke16
strings are immutable
hence when you mutate it, it returns a new one
From IRC (bridge bot)
@FromIRC
<postmodern> also surprised there's no String#tr(Char,Char) overload
George Dietrich
@Blacksmoke16
just use gsub at that point
From IRC (bridge bot)
@FromIRC
<postmodern> what's the equivalent of Regexp.last_match(i) ?
George Dietrich
@Blacksmoke16
"str".scan(...)[-1]?
or use #match with a regex that only matches the last one
<postmodern> crystal docs are not clear what String#gsub(Regexp, &block) yields
<postmodern> also how do you I specify in a type signature Hash(String, String?) | ENV, so a variable could be assigned a literal Hash, or the ENV module
George Dietrich
@Blacksmoke16
looks like it yeilds the matched string an a Regex::MatchData
could prob do like Enumerable({String, String?}) given ENV includes it
but ENV isnt a type, so dont really think it would do what you think
From IRC (bridge bot)
@FromIRC
<postmodern> ah ha
From IRC (bridge bot)
@FromIRC
<postmodern> @Blacksmoke16, I'm guessing ENV.class is not what i want
<postmodern> is there a module or some way of saying "anything that acts like a Hash"
<postmodern> also does crystal seriously not have a StringIO class?
<postmodern> er wait that might be IO::Memory
George Dietrich
@Blacksmoke16
mm dont think so. What are you wanting to do with it?
Enumerable({String, String}) is prob something like what you'd want
there's also String.build
From IRC (bridge bot)
@FromIRC
<postmodern> but will that ensure the given type has a # : String method?
George Dietrich
@Blacksmoke16
it would ensure key/value are both strings, at least when using the methods from that module
From IRC (bridge bot)
@FromIRC
<postmodern> would you be open to me submitting an issue about adding a HashLike (or similarly named) module or abstract class?
From IRC (bridge bot)
@FromIRC
<postmodern> in a module, how would you check if the super was defined before calling super in a method?
<postmodern> in ruby that would be super if defined?(super)
<postmodern> i suspect there must be a macro for checking if a method is defined in the inheritence hierarchy?
George Dietrich
@Blacksmoke16
idt you can without some macro magic
and i doubt that'd idea would fly
From IRC (bridge bot)
@FromIRC
<postmodern> can you define class variables in modules?
George Dietrich
@Blacksmoke16
yes
From IRC (bridge bot)
@FromIRC
<postmodern> such that when the module is extended into a class, it's class variables are defined in the class not the module
George Dietrich
@Blacksmoke16
mm would have to test it
otherwise could maybe make use of like macro extended
From IRC (bridge bot)
@FromIRC
<postmodern> would i have to define the the class variable type inside of a macro extended ?
<postmodern> yeah
<postmodern> ah that works, now i have another error from the specs
From IRC (bridge bot)
@FromIRC
<postmodern> is there a constant for the new-line character/string? "\n" on *nix "\r\n" on windows?
George Dietrich
@Blacksmoke16
dont think so
From IRC (bridge bot)
@FromIRC
<yxhuvud> That'd be nice to have though.
<yxhuvud> might be a mess though. There there still other systems that use "\n\r" ?
From IRC (bridge bot)
@FromIRC
<kevinsjoberg> didn't realize Freenode went ape-shit crazy and banned anyone using IRCCloud. Thank god we moved to Libera.
From IRC (bridge bot)
@FromIRC
<jhass[m]> it's worse, they deleted their entire channel and userdb. It's a new network squatting the old name
Håkan Nylén
@confact
What makes HTTP::Client.get(url).body_io not work when HTTP::Client.get(url).body works? I want to reduce memory somehow, trying to download big files ^^
From IRC (bridge bot)
@FromIRC
<jhass[m]> there's an issue around this somewhere, the interface is just a bit shitty. You want to use the block variant to access body_io, HTTP::Client.get(url) { |response| File.open("dest") {|f| IO.copy(response.body_io, f) } }
Håkan Nylén
@confact
Ah, thanks. Will test it.
Yea, reduced the memory by 60% with that line of code, thanks @jhass[m].
Gabor Szabo
@szabgab
What is the name of the syntax when the condition comes after the statement? (e.g. break if x > 3) in Perl this is called statement modifier, but I don't know how it is called in Crystal