<FromGitter>
<Sija> that's the line which makes it work for this specific case
<FromGitter>
<Sija> did I managed to clear it up for you?
<FromGitter>
<j8r> Sure. So, `includes?` can be modified to avoid this hack? I don't know
<FromGitter>
<Sija> perhaps it would be even better off as another method
<FromGitter>
<Sija> using it in `#includes?` would solve the issue with `contain` without any need of modification
<FromGitter>
<Sija> I'd say that's a good starting point for discussion
<FromGitter>
<Sija> personally I'd even prefer to have it baked in into the `Hash` itself since it's pretty useful outside of spec scenario
<FromGitter>
<j8r> The main issue to fix was essentially a naming one
<FromGitter>
<Sija> that was an issue you've brought, not the *main* one
<FromGitter>
<Sija> > This issue came up for me when I was doing crystal spec with `contains`. Is there an equivalent for `has_key?`? Not sure why `includes?` doesn't have the same behavior...
<FromGitter>
<j8r> Citing @arnavb : > This issue came up for me when I was doing crystal spec with contains. Is there an equivalent for has_key?? Not sure why includes? doesn't have the same behavior...
<FromGitter>
<j8r> Yes, a naming one
<FromGitter>
<j8r> If there was only includes, no questions ask if contain is the same as includes or not
<FromGitter>
<Sija> ok, whatever
Gasher_ has joined #crystal-lang
Gasher has quit [Read error: Connection reset by peer]
Gasher_ has quit [Remote host closed the connection]
<smurfendrek123>
The issue seems to be that i'm cloning an array passed as an argument, Why does the type inference not work when cloning an array?
<smurfendrek123>
How can i assign a class variable to a clone of a method argument?
<FromGitter>
<dscottboggs_gitlab> @smurfendrek123 https://carc.in/#/r/6eig it works if you remove the `protected` and `private`, and define the type in the top level. ⏎ ⏎ You had 2 issues -- 1 you were defining a type in a method, which you can't do, and 2 you weren't defining the type of an instance variable at the top-level.
<FromGitter>
<dscottboggs_gitlab> I realize it's kinda a pain but the type inference system isn't super intelligent and you have to define the types of all instance variables *explicitly* in either all initializers or at the top level of a class/struct
<smurfendrek123>
FromGitter, but now my getter is public?
<FromGitter>
<dscottboggs_gitlab> OH perhaps it's because `#initalize` is an implicitly called method... I think you might have found a bug
<smurfendrek123>
I'll make an issue on github then?
<FromGitter>
<dscottboggs_gitlab> yeah, check to make sure it hasn't already been raised though, kinda weird this hasn't already been encountered
<FromGitter>
<dscottboggs_gitlab> `#initlize` imlicitly defines `self.new` which allocates the memory then calls the initialize method, sets up the GC etc.
<FromGitter>
<dscottboggs_gitlab> I think it's working as intended actually
<FromGitter>
<dscottboggs_gitlab> https://carc.in/#/r/6eii ⏎ ⏎ `private def initialize` defines a `private def self.new`, but `protected def initialize` just defines a regular `self.new`? I bet `protected def self.some_method` doesn't work
<smurfendrek123>
FromGitter, so how do i make my initialize protected?
<smurfendrek123>
dscottbogs_gitlab should i make my class protected? but what if i want to be able to use the class outside the module, but not create new objects of it
<FromGitter>
<dscottboggs_gitlab> smurfendrek123 https://carc.in/#/r/6eir perhaps this will help?
<smurfendrek123>
yup, thanks!
<FromGitter>
<dscottboggs_gitlab> np!
<FromGitter>
<dscottboggs_gitlab> but I do think this is an issue you should raise on github.
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
azuri5 has joined #crystal-lang
<FromGitter>
<kimvex> Hello, how can I send an object via ⏎ ⏎ `HTTP :: Client.post ("http://server.com/upload", body: {"name_image": "my image", "File": file})`
laaron has quit [Remote host closed the connection]
<FromGitter>
<j8r> do someone knows if there is a macro for Time to avoid the use of `date "+%Y.%m.%d"`
<FromGitter>
<mamantoha> @j8r there is no such macro :( I'm using `crystal eval 'puts Time.now.to_s("%Y.%m.%d")'`.stringify.chomp
<FromGitter>
<j8r> lol that's even worse than `date` @mamantoha :)
<FromGitter>
<mamantoha> I know
<FromGitter>
<j8r> anyway thanks for the response!
<FromGitter>
<mamantoha> I thought about multi-platform support, but actually, I need only Linux
<FromGitter>
<j8r> it works also on macos an bsd
Gasher has quit [Remote host closed the connection]
Gasher has joined #crystal-lang
ua_ has quit [Ping timeout: 250 seconds]
Gasher_ has joined #crystal-lang
Gasher has quit [Read error: Connection reset by peer]
ua_ has joined #crystal-lang
<FromGitter>
<vladfaust> Hey guys, I'm looking for Phoenix error template in HTML format. Googling and lurking in its repository gave no result, I just can't find the needed file. Moreover, I remember having seen the template adapted for Crystal, but can't find it as well...
<FromGitter>
<vladfaust> Yes, thank you very much, @anamba!
ternarysolo has quit [Ping timeout: 250 seconds]
<FromGitter>
<arnavb> Regarding yesterday's discussion, issues, and PR's for `contains key:`, the problem I see with `x.has_key("key").should be_true` is that when the assertion fails, then it will output something along "expected true, but got false". Sure, good spec naming would solve this, but IMO a better alternative would be to do what rspec does, which is have a `have_key` matcher. This way, when an assertion fails, it might
<FromGitter>
... fail with something more clear than what I mentioned before. ⏎ ⏎ Regarding checking for a key value pair using `contains`, this isn't feasible for me because I'm dealing with JSON data with lots of nested properties; listing a value for these would just be tedious.
<FromGitter>
<whitenoiseoss> so in this case, this builds, which i'm guessing means everything needed was found okay. but @[Link("lynyrdskynyrd")] doesn't error because until it runs into a problem it doesn't care? it'll attempt to find a lynyrdskynyrd.h each time it sees a new fun?
<FromGitter>
<r00ster91> try calling the function
<FromGitter>
<r00ster91> I don't think this does anything yet
<FromGitter>
<whitenoiseoss> so really all `@[Link("blah")]` does is throw `-lblah` to cc
<FromGitter>
<r00ster91> yeah pretty much
<FromGitter>
<whitenoiseoss> so @r00ster91 one more question, and this one is more of a doozy
<FromGitter>
<whitenoiseoss> I've been writing a special Lua compiler, but @[Link("lua")] worked for that and was up up and away...for writing Postgres extensions there is a lot more work in it...and I need to build with this makefile: https://github.com/postgres/postgres/blob/master/src/makefiles/pgxs.mk
<FromGitter>
<whitenoiseoss> can a Crystal Makefile do that?
<FromGitter>
<whitenoiseoss> this might be a problem rooted in my generated cc line is wrong
<FromGitter>
<whitenoiseoss> CGO can actually just use a C Makefile, so that's how that one does it
<FromGitter>
<whitenoiseoss> I'm not 100% sure how the Rust one is working, Rust is kind of a cluster syntax-wise
<FromGitter>
<dscottboggs_gitlab> you just bind to the .h file and then use crystal build. You just need to get it working as a C library and then do that and LLVM should take care of the rest
Groogy has quit [Quit: WeeChat 2.4]
DTZUZO has joined #crystal-lang
<FromGitter>
<whitenoiseoss> @dscottboggs_gitlab I am not sure what you mean. "bind to .h file"? also, "get it working as a C library" -- I am sure you know this, but I am trying to wrap the C libraries, so are you saying I should build the PG extension as a C library and then pull it in as a shared library?
<FromGitter>
<whitenoiseoss> my objective would be to have only Crystal source
<FromGitter>
<whitenoiseoss> the folks I would be writing this for wouldn't want to maintain C
<FromGitter>
<dscottboggs_gitlab> TBH idk, I'm not to great with C building and linking. I'm trying to bind libav right now. I'm on ubuntu 18.04, so I installed `libavcodec-dev` which put all the `.h` files into my `/usr/include` default search paths. Then, to test it out, I wrote this little lib: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c7c07d4e8ea143737a6f5b8]
<FromGitter>
<dscottboggs_gitlab> and it worked! I just did `crystal run` and the linking worked
<FromGitter>
<whitenoiseoss> oh ok I see
<FromGitter>
<whitenoiseoss> yes! that is how my Lua code works.
<FromGitter>
<whitenoiseoss> as you can see..one second..
<FromGitter>
<dscottboggs_gitlab> `avcodec_version` is defined in `avcodec.h`
<FromGitter>
<dscottboggs_gitlab> what kind of system are you running?
<FromGitter>
<whitenoiseoss> I'm on Ubuntu 16.04 with this, as the Windows Linux subsystem
<FromGitter>
<whitenoiseoss> but if you think it would help, I could reboot into Ubuntu 18.10 (Pop OS)
<FromGitter>
<dscottboggs_gitlab> ok. And you have libfmgr-dev packages etc installed?
<FromGitter>
<dscottboggs_gitlab> no any ubuntu is fine I just wanted to make sure you weren't trying to do this on MacOS lol :p
<FromGitter>
<whitenoiseoss> ```code paste, see link```
<FromGitter>
<whitenoiseoss> i *think* that's sufficient
<FromGitter>
<dscottboggs_gitlab> does `dpkg -L postgresql-server-dev-11` help any?
<FromGitter>
<whitenoiseoss> it just shows me the paths to the stuff I showed up at my first paste
<FromGitter>
<dscottboggs_gitlab> there's also `libpq-dev` which might be what you're looking for
<FromGitter>
<whitenoiseoss> which, as you can see from that one, the fmgr.h and postgres.h are in there
<FromGitter>
<whitenoiseoss> hm, let me look at it
<FromGitter>
<whitenoiseoss> libpq is the C application programmer's interface to PostgreSQL. libpq is a set of library functions that allow client programs to pass queries to the PostgreSQL backend server and to receive the results of these queries.
<FromGitter>
<whitenoiseoss> hmm
<FromGitter>
<whitenoiseoss> I guess it can't hurt to try it
<FromGitter>
<whitenoiseoss> oh
<FromGitter>
<whitenoiseoss> ```libpq-dev is already the newest version (11.2-1.pgdg16.04+1).```
<FromGitter>
<paulcsmith> Does anyone know how to use a NamedTuple generic in an instance variable. I’m trying to pass along options to another class but can’t figure out a way
<FromGitter>
<TheOnlyArtz> Hey! How would I be able to add new elements to JSON::Any?
<FromGitter>
<Blacksmoke16> would have to look into JSON::Builder or something
<FromGitter>
<TheOnlyArtz> But JSON::Any != JSON::Builder
<FromGitter>
<TheOnlyArtz> I can't do JSON::Any.field, it's not a thing.
<FromGitter>
<Blacksmoke16> yea, iirc JSON::Any is immutable from reading JSON string
<FromGitter>
<TheOnlyArtz> O_o
<FromGitter>
<TheOnlyArtz> Nice to know
<FromGitter>
<TheOnlyArtz> Can I parse Any to Builder?
<FromGitter>
<TheOnlyArtz> Actually it looks like I can construct one directly from the desired IO
<FromGitter>
<Blacksmoke16> well there you go
<FromGitter>
<TheOnlyArtz> I can't manage to have the builder to be readable
<FromGitter>
<TheOnlyArtz> I want to be able to read JSON's properties AND change it's properties
<FromGitter>
<arnavb> Can someone explain this to me? I don't understand the behavior shown in this: ⏎ ⏎ ```{"a" => nil} ⏎ false ⏎ {"a" => nil} ⏎ true``` ⏎ ⏎ Why is the output different for the hash vs. the JSON and how can I make it output true instead? [https://gitter.im/crystal-lang/crystal?at=5c7c26bc47276019e9ad837c]
<FromGitter>
<Blacksmoke16> would have to read it in via JSON.parse, then create a new JSON.build to build new structure with changes
<FromGitter>
<TheOnlyArtz> uh that's what I thought about @Blacksmoke16 but it seems like a long way
<FromGitter>
<TheOnlyArtz> Ok I will use it
<FromGitter>
<Blacksmoke16> @TheOnlyArtz is prob better to look into like creating objects from the json vs json.parse
<FromGitter>
<TheOnlyArtz> Though, according to the website I should be able to go `JSON.to_json(JSON::Builder)`
<Yxhuvud>
Hmm. Suppose I have a Slice with the exact same lifetime as the object that creates it (that also is the only thing that refer to elements in it), is it possible to embed it in the owning object somehow?
<FromGitter>
<Blacksmoke16> got a playground link?
<FromGitter>
<TheOnlyArtz> I'm working on my system
<FromGitter>
<TheOnlyArtz> I can link the code
<FromGitter>
<arnavb> Ok, so using `== nil` made the example output true. Why does `.nil?` not work though?
<FromGitter>
<Blacksmoke16> you only need the `to_json(builder)` when overriding the `to_json` behavior, for like custom types and stuff
<FromGitter>
<Blacksmoke16> otherwise everything just works
<FromGitter>
<Blacksmoke16> @arnavb give me a min i can take a look
<FromGitter>
<Blacksmoke16> i can make an example in a few
<FromGitter>
<TheOnlyArtz> https://ghostbin.com/paste/ed9nx @Blacksmoke16 ⏎ Please don't mind the work flow , I just started with crystal today, relevant lines: 45 ` File.write(DB_PATH, JSON.to_json(db_builder))`
<FromGitter>
<Blacksmoke16> well you're not actually writing anything
<FromGitter>
<TheOnlyArtz> Because it doesn't work
<FromGitter>
<Blacksmoke16> sec
<FromGitter>
<TheOnlyArtz> I'm trying to write the JSON string
<FromGitter>
<TheOnlyArtz> But I can't manage to extract one
<FromGitter>
<Blacksmoke16> yea, moment
<FromGitter>
<TheOnlyArtz> Sure 😄
<FromGitter>
<Blacksmoke16> you should just be able to write the output of the io
<FromGitter>
<TheOnlyArtz> What IO?
<FromGitter>
<Blacksmoke16> the one that you're passing to `JSON::Builder.new`
<FromGitter>
<TheOnlyArtz> Oh wait ok I know what to do
<FromGitter>
<Blacksmoke16> Yea you'll need to start/end the document and object
<FromGitter>
<Blacksmoke16> but there is prob a better way to go about doing this
<FromGitter>
<arnavb> So wait, does that mean I have to explicitly cast it to nil?
<FromGitter>
<Blacksmoke16> is there another type it could be?
<FromGitter>
<arnavb> It's a nilable type so, it could be a string, int, bool, or nil
<FromGitter>
<Blacksmoke16> `p json["a"].as_s?`
<FromGitter>
<Blacksmoke16> `.nil?`
<FromGitter>
<Blacksmoke16> thats saying try to cast the value as a string, otherwise return nil
<FromGitter>
<arnavb> Huh.
<FromGitter>
<arnavb> Thanks
<FromGitter>
<Blacksmoke16> again, similar to what @TheOnlyArtz is doing it would prob be better to create objects from the json vs just using `JSON.parse`
<FromGitter>
<Blacksmoke16> yes, having access to that would be great
<FromGitter>
<vladfaust> We used to argue with @asterite on this topic. And he said that "at this moment (i.e. in finished macro) instance variables are not fully known blah-blah". But we do have an access to *instance methods*. I feel like it's *unconsistent behavior* and if we have access to instance methods, we should have one to instance variables then.
* FromGitter
* vladfaust now afraids that Ary will remove .methods
<FromGitter>
<Blacksmoke16> my usecase was for using an annotation on an `property` def to override the getter to be a DB query
ua_ has quit [Ping timeout: 250 seconds]
<FromGitter>
<Blacksmoke16> oh well
<FromGitter>
<straight-shoota> @vladfaust I'm not very familiar with the semantic stage. But from what I understand, I think the issue is that while both ivars and methods are not fully known, that's not an issue for methods, because they don't need a type. So it doesn't matter if they're fully typed. But instance variables always have a type, but at that point, it might not be known.
ua_ has joined #crystal-lang
<FromGitter>
<straight-shoota> I'm not sure this assessment is 100% correct.
<FromGitter>
<straight-shoota> @vladfaust with your crazy idea you're derailing your own issue
<FromGitter>
<vladfaust> I'd better delete it an leave for separate one
<FromGitter>
<vladfaust> Hey, @straight-shoota you've said on Reddit that language is not expected for big changes
<FromGitter>
<vladfaust> What's the status on removing Symbols then?
<FromGitter>
<vladfaust> I'm not pursuing my own issue, just wondering
<FromGitter>
<vladfaust> It is often seen in issues
<FromGitter>
<vladfaust> No problem if don't have anything to answer yet, I understand, sorry
<FromGitter>
<straight-shoota> Yeah. I wouldn't consider that a huge change. After all, it would just change some semantics but I figure most uses of symbol literals wouldn't even need any changes, when the API switches to enum instead.
<FromGitter>
<straight-shoota> There is no decision on that topic though, not even a serious discussion about implications.
<FromGitter>
<vladfaust> It should be done anyway -- the discussion, sooner or later
<FromGitter>
<straight-shoota> But there is some drive to it, and I can definitely see symbols going away.
<FromGitter>
<vladfaust> The team should consider symbol literal arguments, though
<FromGitter>
<vladfaust> They bring much beauty to the language and familiar to Ruby devs
<FromGitter>
<vladfaust> I'm sure there are other usecases where Enums are redundant but some kind of compile checks must be run depending on arguments
<FromGitter>
<straight-shoota> It's not a bad idea, but it would be hard to implement. And it would be strange to have two different semantics for symbol literals.
Gasher_ has quit [Remote host closed the connection]