crystal-lang Questions

3

I am writing an Nginx configurations for Crystal-Lang based application to send all the traffic http://example.com/videos/ to http://0.0.0.0:3000 via reverse proxy. I have written the following con...
Alms asked 12/10, 2021 at 5:43

2

Solved

Are there any multi line comments in Crystal ? Such as Ruby does : =begin this is a multiline comment in Ruby =end This will simply give me an error in Crystal : unexpected token: =
Katheykathi asked 6/10, 2017 at 22:43

2

Solved

I like eval in Ruby because it works pretty straightforward: eval("puts 7 * 8") # => 56 What is an eval's equivalent in Crystal ? I know that we can do something similar with macro: macro ev...
Luminescence asked 24/6, 2015 at 20:17

6

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 modification)...
Avisavitaminosis asked 16/3, 2017 at 20:53

3

Solved

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...
Broken asked 17/2, 2017 at 13:20

2

Solved

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? T...
Prentiss asked 11/7, 2020 at 17:47

2

Solved

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.
Classroom asked 1/9, 2018 at 7:30

2

Solved

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...
Crat asked 18/2, 2016 at 20:34

2

Solved

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 J...
Raleighraley asked 19/3, 2018 at 9:2

2

Solved

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...
Escapee asked 17/2, 2018 at 20:53

2

Solved

I'm testing about serialization with bytes or slices, just learning and trying. I would like to bind 3 parameters in a single 10 bytes field, but I don't now how to concatenate them in Crystal or w...
Kuster asked 3/6, 2018 at 1:46

1

Solved

I recently picked up on Crystal after being a Rubyist for a while, and I can't seem to find anything about the File class. I want to open and read a file, but it gives me an error. file = File.ope...
Mavismavra asked 25/4, 2019 at 15:17

2

Solved

I'm writing a program in Crystal, that I intend to compile and move to other systems for execution. Ideally, it should have no dependencies, as the target systems will be fresh installations of lin...
Celloidin asked 3/2, 2016 at 0:28

1

Solved

this is my first Stackoverflow question :-) My background: 2 years Python experience 2 months crystal-lang experience ( websites running with Amber framework ) 1 month into C, C++ , assembly ...
Idden asked 18/10, 2018 at 15:10

1

I am not sure if this is a bug. But I've been playing with big and I cant understand why this code works this way: https://carc.in/#/r/2w96 Code require "big" x = BigInt.new(1<<30)...
Ludovick asked 12/10, 2017 at 13:40

1

Solved

I am trying to process the following JSON that I receive from an API. {"product":"midprice", "prices":[ ["APPLE","217.88"], ["GOOGLE","1156.05"], ["FACEBOOK","160.58"] ]} I can get a basic ma...
Buggy asked 18/9, 2018 at 1:59

2

Solved

I was wondering if I simply cannot find a between method for numbers in Crystal. In Ruby, there's the Comparable#between? method which can (among others) compare two numeric values (my specific ca...
Archduchy asked 3/8, 2018 at 9:5

1

Solved

Both syntaxes look rather equivalent, and their use cases are similar too. Example: # Hash hash = {"name" => "Crystal", "year" => 2011} hash["name"] # outputs: Crystal # NamedTuple tuple = ...
Rosenblast asked 27/7, 2018 at 15:39

3

Solved

puts "Input a number" A = gets.try(&.to_i) || 0 puts "Ok now another number" B = gets.try(&.to_i) || 0 def main puts "Value of multiplication is #{A} * #{B}, Which equals = #{A * B}" pu...
Colewort asked 26/7, 2018 at 6:43

1

Solved

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&qu...
Balbriggan asked 13/7, 2018 at 8:1

1

Solved

I want to access the serial port using Crystal lang. I have following code in python. I want to write the equivalent Crystal-lang code for a pet project. import serial def readSerData(): s = s...
Punish asked 27/6, 2018 at 18:47

1

Solved

I have a Kemal-based RESTful web service that returns "very big" (from 10 to 17M in size) chunks of JSON data, which is produced by to_json method from the "big" Hash structure. According to GC w...
Dunite asked 9/6, 2018 at 12:48

2

Solved

In Crystal, there's two different ways to achieve similar results: Creating a class... class Service def self.get # ... end end or a module extending self: module Service extend self def...
Erkan asked 6/5, 2018 at 14:29

3

Solved

I read the documentation on Procs in the Crystal Language book on the organizations’s site. What exactly is a proc? I get that you define argument and return types and use a call method to call the...
Radish asked 15/3, 2018 at 5:21

2

Solved

While reading through the Crystal docs, I came across this line: deq = Deque{2, 3} So I think this calls the Deque.new(array : Array(T)) constructor. However, I did not find any documentation a...
Canula asked 14/3, 2018 at 12:34

© 2022 - 2024 — McMap. All rights reserved.