내 간단한 클래스는 HTTPS를 통해 PEM 인증서가있는 웹 서비스를 요청할 수 있습니다. require [omit verbose]
class Api
def initialize
@ctx = OpenSSL::SSL::Context::Client.new
@ctx.private_key = "/home/XXXXXX/develop
매크로에서 유니온 타입의 타입을 반복 할 수있는 방법이 있습니까? 여기 내 시도입니다 : alias MyType = Int32 | String
{% for type in MyType.union_types %} #=> undefined method 'union_types' for TypeNode of type MyType (must be a union t
언어로 실험 한 결과 select은 전역 범위에 정의되어 있으며 그 우선 순위는 로컬 변수보다 높습니다. def example(select)
puts select
end
example 3
# Syntax error in eval:3: unexpected token: end (expecting when, else or end)
그래서 단계별
임의의 개체 형식에서 메서드를 호출하려고하는 유틸리티 라이브러리를 작성하려고합니다. 유형으로 우리가 알 수없는 그래서 Can't infer the type of instance variable 'object'의 컴파일러 오류가 나는 크리스탈에서이 작업을 수행하는 방법을 잘 모르겠어요 def foo(object)
object.public_send(:
HTTP를 통해 API로 보내진 클래스가 있고 모든 속성 (nils 포함)을 가진 json으로 내보낼 필요가 있습니다. class Customer
JSON.mapping(
id: UInt32 | Nil,
name: String | Nil,
email: String | Nil,
token: String
)
내가 크리스탈 랭에서 간단한 JSON 매핑 된 객체를 가지고 가정하자 , 예를 들면 : 쉽게 그래서 같은 JSON 문자열에서 class Item
JSON.mapping(
id: UInt32,
name: String,
)
end
내가 구문 분석 할 수있는 개별 개체 : foo = Item.from_json(%({"id":1,"
Crystal 프로그래밍 언어로 응용 프로그램을 작성하고 있습니다. Crystal에 대해 좋아하는 것 중 하나는 Logger 유틸리티와 같은 광범위한 표준 라이브러리입니다. 로깅 구문은 다음과 같습니다 require "logger"
log = Logger.new(STDOUT)
log.level = Logger::WARN
log.debug("Crea