我有一个has_many items的Rails模型
class Plan < ApplicationRecord
extend T::Sig
has_many :items, dependent: :destroy
before_save do
# hyper simple test method to illustrat problem
puts items
end
end
然而,冰沙似乎不能与has_many :items联系起来。当我运行Sorbet类型检查时,我得到以下错误:
$ srb tc
app/models/plan.rb:11: M
我有一个文件my_class.rb # typed: true
class MyClass
attr_accessor :a, :b
def initialize(a: 1, b: 2)
@a = a
@b = b
end
def do_stuff
puts "#{self.class}: #@a #@b"
a * b + a - b
end
end 读完installing and initializing Sorbet之后,我决定用sorbet/rbi/my_class.rbi为这个文件写一个RBI签名 # typ
我使用rails-observers gem,我不能运行srb tc而没有错误.
app/models/supplier_observer.rb:3: The super class ActiveRecord::Observer of SupplierObserver does not derive from Class https://srb.help/5067
3 |class SupplierObserver < ActiveRecord::Observer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
这类似于我在中的问题,但对于常量。
我正在实验添加冰糕类型的信息到我的宝石,pdf-阅读器。我不希望sorbet成为gem的运行时依赖项,因此所有类型的注释都在rbi/目录中的一个外部文件中。我也不能在类中扩展T::Sig,也不能在代码中使用T.let。
我想在一些文件中启用typed: strict,但是这样做会导致常量没有类型注释:
$ be srb tc
./lib/pdf/reader/buffer.rb:41: Constants must have type annotations with T.let when specifying # typed: strict https:/
我们开始在工作中使用yard,但srb init抛出了一个要求使用索贝特的错误。文件仍然生成,并且看起来工作正常,直到srb tc开始产生如下所示的错误: sorbet/rbi/todo.rbi:38: PG::Error was previously defined as a class https://srb.help/4012
38 |module PG::Error; end
^^^^^^^^^^^^^^^^
sorbet/rbi/hidden-definitions/hidden.rbi:121092: Previous definition
我有以下泛型类型定义:
# typed: true
class A
extend T::Sig
extend T::Generic
Value = type_member
sig { params(value: Value).void }
def initialize(value)
@value = value
end
sig { returns(Value) }
def value
@value
end
end
当我展示#value的类型时,我希望它是Integer,但它是T.untyped
v = A.new(42)
T
我将冰沙从v0.5.5569更新到v0.5.5753。在更新之前,我在运行bundle exec srb tc时有0个错误,但是在更新之后,我得到了Errors: 66。我决定运行bundle exec srb rbi update会有所帮助。但它在RuntimeError中失败了,这是回溯: Generating /tmp/d20200612-571-3e8xq8/reflection.rbi with 13952 modules and 216 aliases
Printing your code's symbol table into /tmp/d20200612-571-3e
我想允许用户从应用程序上传文件,它必须通过WebSocket连接,我很难找到解决方案,到目前为止,我找到的所有解决方案都需要设置Content-Type头,而对于WS连接,我无论如何都找不到这样做 上传文件的JavaScript代码: const fd = new FormData();
fd.append('uri', uri)
// I get the URI from user gallery expo-image-picker
// The URI looks like this: file:/data/user/0/host.exp.exponent/cache
我正在一个实验性的开源项目()中试用Sorbet。我不知道如何让类型检查与嵌套测试项目中的一些RSpec测试一起工作。当我运行srb tc时,我看到一些类型检查错误,如:
spec/src/example_class_annotated_spec.rb:6: Method it does not exist on T.class_of(<root>) https://srb.help/7003
6 | it 'should add @foo and @bar' do
7 | instance = ExampleClass.new(2, 3
我的代码存在问题,该代码解析输入文件(如下图所示),并将信息存储在列表/字典的组合中。
我有一个CSV文件,其中有类似于此的行(它们是Baseball统计数据):
Reyes,Jose,Mets,SS,681,191,36,12,12,57,.280
现在,我能够将每个字段分开,并将其正确地存储在变量中,但当我必须将数据存储在数据结构中时,这个问题就会起作用。
我必须存储每个球员的统计数据,然后将球员存储在他们所属的每支球队的迪克特/名单中。
我的思考过程与此类似:
DICT OF TEAMS (TEAM IS KEY, VALUE IS A DICT OF PLAYERS)
|
V
DICT
我在做一个闪光塔防御游戏。我有一个叫“塔”的片段。在这段视频中,你可以找到所有的塔类型(火、毒、冰等)。基本上,我做gotoAndStop("tower type here")是为了选择正确的塔。所有这些“塔类型”也是剪辑,在这些剪辑中,你可以找到这种塔类型的演变(每次你“升级”你的塔,它的外观会改变…这是一种进化)。每个进化都是一个片段,在这个片段中有一个声音(当塔向敌人射击时我必须播放的声音)。我做gotoAndPlay("shoot")。
问题是,即使有stop(),我们也能听到信号塔的声音,而且不应该有任何声音。我注意到一件事。如果我去掉每个塔类型的第一