Is there an equivalent to Pry for Crystal?

I am very new in crystal language. I would like to know if a debugger like Ruby's Pry exists in Crystal? It means that you can put in code something like 'binding.pry' at program stop execution at...

Git warnings when updating homebrew OS X

Last login: Mon Mar 7 17:35:51 on console ~ brew update warning: unable to access '/Users/Jason/.config/git/ignore': Permission denied warning: unable to access...

How do I access an object's eigenclass in Crystal?

In Ruby, it's possible to access the eigenclass (or "singleton class") of an object by reopening it. This is particularly useful for defining "private class methods": class Foo class << self ...

Crystal How to check if the block argument is given inside the function

Suppose a function defined like this: def composition(text : String, k : Int32) : Array(String) kmers = Array(String).new (0 .. text.size - k).each do |i| kmers << text[i, k] yield...

Crystal: How can I find the SHA256 hash of a binary value?

I'm new to Crystal. I'd like to try and find the SHA256 hash of a hex string. I've managed to get something working: sha256 = OpenSSL::Digest.new("sha256") puts sha256.update("abcd") But I'm not...

Encoding.ASCII.GetBytes(cArr) in Crystal

I'm converting some C# code into Crystal code for a project: my goal is to convert a string into an ASCII Byte array. C# code The C# code is the following: string expression =...

ld: library not found for -lssl

I installed crystal with homebrew brew install crystal-lang. I was able to compile and run a "Hello World!" program, but when I try to compile the example http server (with one slight...

Getting info about inheritance chain in Crystal

Just out of curiosity and to learn a little bit about the general structure of Crystal, I was looking for some reflection features that would allow me to better understand how the inheritance...

Crystal native GUI

Does Crystal possess any native GUI libraries ? There is already a few shards that implement known libraries such as QT or SFML ( anything related to C in fact ) but i need a native library as I...

equivalent of ruby `block_given?` in crystal

Ruby has this method called the block_given in it so that we can check to see if a block is passed and process accordingly if given. Is there an equivalent method in crystal?

Starting crystal in production mode

I've been running my Crystal webapp by building it, and then running the executable. However, it always listens on port 3000. How do I build/run Crystal webapps listening on 80 and 443? I'm using...

Crystal equivalent to algebraic data types

What is the idiomatic way to write the equivalent of an algebraic data type in Crystal? E.g. In Haskell I might have data Stage = StageInitial String | StageFinished String So I want to have...

Threading HTTP requests in Crystal

I have code that needs to run in "parallel" (not real, I know Crystal does not support parallelism). require "http/client" thread_count = 4 resps = [] of HTTP::Client::Response mutex =...

Timers/Intervals in Crystal Lang

Is there a timer or interval function in Crystal? I checked the docs for a timer, interval, and under the Time class, but did not see anything. Something like setInterval() or setTimeout() from...

axios upload to node.js API results in files in aws s3 becoming unreadable

Screen of UploadScreen of DownloadWhenever I utilize the client side upload panel the files that get uploaded to the bucket are named correctly but wont open. They are also a slightly different...

How can I convert a String to an Integer or Float in Crystal?

In Crystal, how can I convert a String to an Integer or Float? Using Python I can simply do the following: >>> nb = "123" >>> int(nb) 123 >>> nb = "1.23" >>> float(nb) 1.23 Are there any similar...

Crystal lang : How to indicate require path for crystal compiler

If some of my libraries locate out of default directory lib, could I indicate the require path to compile successfully without lib directory nor shards.yml.

Query Interface for Lucky Framework

How can I test/write queries in a terminal (Query Interface) for Lucky Framework (similar to rails console in RoR)

Cycling between Fibers with no IO

As far as I know, crystal cycles Fibers with io, meaning that if one fiber is waiting for io, crystal will switch to an another fiber. What if we spawn two fibers but one of them does constant...

Crystal Lang Websocket server

I need help with Crystal Lang websockets, I want to know how to upgrade my connection on websocket. I want make simple websocket server

How to access global variables inside functions

I have following simple code: line = "Hello" def myfn() puts line end myfn() The variable line is not accessible in function. How can global variables be accessed inside functions?

Error: undefined method 'x' for Nil (compile-time type is (Point | Nil))

I'm writing a test that checks coordinates of a point to have a certain value, e.g.: it "should work" do p = do_something # returns a Point(x, y) p.x.should eq 0 # errors (see...

Fibonacci problem causes Arithmetic overflow

The problem: create a function with one input. Return the index of an array containing the fibonacci sequence (starting from 0) whose element matches the input to the function. 16 ~ │ def...

Is there any alternative to python ast module in Crystal?

Does Crystal expose its internal parser as a standard library as python does with it's ast module? How to parse crystal source code and get the AST of it?

What is the "&-=" operator in Crystal Lang?

I just learned about the existence &-= operator in Crystal. What does it do? Here is an example from Mutex#try_lock: private def try_lock i = 1000 while @state.swap(1) != 0 while...

Can this Crystal benchmark code be improved significantly?

I'm deciding on a language to use for back-end use. I've looked at Go, Rust, C++, and I thought I'd look at Crystal because it did reasonably well in some benchmarks. Speed is not the ultimate...

Is there a way to see what a Crystal macro expands to?

I've a macro that refuses to work as expected and I was wondering if there was a way to see what it expands to, is there something like macroexpand-1 from lisp in Crystal? If so, how do I use it? Thanks!

Is there a way to do one-liners in Crystal language?

I'm a user of the Ruby language, and while the idea of using the Crystal language as a one-liner may be silly, the Crystal language is so fast that even when you add up the compile time, it can...

In Crystal FFI, how do I access a type in the C library?

The task I'm working on is to add support for the create_function interface to Crystal's SQLite binding: https://github.com/crystal-lang/crystal-sqlite3/issues/61 To access the parameters for a...

Why can't Crystal resolve the type of the assignment of 1 + 1?

What's the reason why Crystal can't/won't resolve the type of this? (I see that the documentation does not mention that the compiler could infer instance method calls, but what's the rationale...

Relevant tags