crystal-lang Questions

1

Solved

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 two...
Anatolia asked 27/2, 2018 at 0:12

1

Solved

Just discovered Amber...looks nice! How can I deploy a sample App on an Ubuntu Server? Should it be done just like Rails, routing the path to public? Or some other part of the structure? Thanks fo...
Claudication asked 9/2, 2018 at 10:52

1

Solved

Coming from the Ruby world, I instantly understood why Crystal chose not to implement a for method. But then I was surprised to see that Crystal does implement a for method for macros. I was even m...
Briolette asked 30/12, 2017 at 19:15

1

Solved

How to map parsed JSON as JSON::Any type to custom Object? In my case, I am working on chat client. Chat API can respond to requests with following JSON: {"ok" => true, "result" => [{"upd...
Vane asked 29/12, 2017 at 1:30

2

Solved

I have a crystal-lang project on Amber framework with Jennifer.cr and I'm getting this error on my controller: Can't infer the type of instance variable '@companies' of CompanyController @companie...
Inclined asked 24/10, 2017 at 16:55

1

Solved

Is possible to use method proc with parameters in Crystal ? Something like: def foo(baz) puts "#{baz} foo!" end proc = ->foo proc.call "Hi"
Murrhine asked 13/10, 2017 at 11:12

3

Solved

I want to execute a shell script while handling stdout and stderr output. Currently I execute commands using Process.run, with shell=false and three pipes for stdin, stdout and stderr. I spawn fibe...
Citystate asked 18/2, 2016 at 14:51

1

Solved

How do I choose how to pass a variable by value or reference using Crystal ? Exemple : I would like to pass a Struct by reference and not by Value ( the documentation explains that it is passed by...
Suave asked 7/10, 2017 at 23:39

1

I am trying to learn to debug programs written in Crystal with GDB. Here is a sample: class Demo @array = [] of String def bar(url) ret = url.downcase * 2 if ret == "alsj" return false else...
Swagsman asked 22/9, 2017 at 16:56

1

Solved

Suppose I've got a simple JSON mapped object in Crystal lang, e.g.: class Item JSON.mapping( id: UInt32, name: String, ) end I can parse individual objects from JSON strings easily like so: ...
Main asked 15/9, 2017 at 19:50

1

If a developer compiles a Crystal program, what metadata will the binary file store and how to remove any sensitive information? By sensitive I mean device identificators, local IP addresses or any...
Intradermal asked 11/9, 2017 at 17:0

1

Solved

I need to verify if a constant is defined to do a conditional. I was trying this but "defined" method not exists on this language: if defined(constant) value = :foo else value = :bar end
Isadora asked 27/8, 2017 at 18:4

1

Solved

Is recursive proc posible in Crystal? Something like lambda in Ruby I'm trying to do a y-combinator in Crystal,something like Ruby one: puts -> { fact_improver = ->(partial) { -> (n) ...
Disorderly asked 21/7, 2017 at 12:15

1

Solved

I was just wondering about the compiler speed of the Crystal programming language. It feels relatively slow: ➜ ~/Code/crystal/crystal_scheduler (master ✘)✹✭ ᐅ time crystal build --release src/crys...
Gilbart asked 18/6, 2017 at 10:23

1

I'm creating a m3u8 generator/parser for crystal, yet I want to use it later with ruby. Is that possible/easy to do it?  
Nanettenani asked 1/2, 2016 at 10:47

2

Solved

I'm running a program which allocates 8mb stacks using mmap. While testing to see how many stacks I could allocate (aiming for 100,000), I see virtual memory size rise quickly as expected, and rese...
Intercontinental asked 21/12, 2016 at 17:0

1

Solved

When I try to add it to sources as per debian install instructions I get this error. I'm guessing this means that there are no arm packages for it. Failed to fetch https://dist.crystal-lang.org/...
Comfy asked 14/3, 2017 at 20:40

1

Solved

I’m trying to figure out how c bindings in crystal work. For starters I’m wondering how I would include a simple hello world c function into crystal. Always good to start with the basics right? Her...
Sweatbox asked 13/3, 2017 at 21:24

1

Solved

I have a function with this signature: const char* get_version(); My declaration is: fun get_version(): LibC::Char* And to use it: version = MyLib.get_version() puts version # how to convert...
Sacksen asked 28/12, 2016 at 1:16

1

Solved

I want to convert an hex string value in a variable to int. This works for a literal: "#{0xFF}".to_i But with a var...? Not working test (interpolation error): _myvar = "FF" "#{0x_myvar}".to_i ...
Karli asked 25/12, 2016 at 9:21

1

Solved

How can I read a single char from the console without pressing enter / return? In ruby I would just use: require 'io/console' input = STDIN.getch
Vladimar asked 10/10, 2016 at 17:52

1

Solved

Developers say that Crystal follows Ruby language syntax. So can I (or would I, in the future) just require a Ruby gem and it magically builds and properly working and so on?
Fletcherfletcherism asked 22/2, 2016 at 20:56

1

Solved

I would very much like to know what exactly makes Crystal faster than Ruby while code is so similar. The short answer could be that it is compiled, and Ruby is interpreted, yet I would like to unde...
Hyperplasia asked 22/2, 2016 at 12:2

1

Solved

Is it possible to use a shorthand for blocks in Crystal, e.g. my_array.sort_by(&:size) This attempt returns an error: ... expected a function type, not Symbol
Prothesis asked 22/2, 2016 at 11:31

1

Solved

The title says it all. Maybe there's a method can be called like def destruct; delete self;end?
Canoness asked 8/2, 2016 at 6:14

© 2022 - 2024 — McMap. All rights reserved.