如何更新github上的分支[复制](How to update a fork on github [duplicate])
这个问题在这里已经有了答案:
- 我如何更新GitHub分叉库? 16个答案
我在github上分发了一个回购并改变了一些东西。 最初的回购已经犯了一些事情。 我如何更新我的分叉而不重新分割并撤消所有更改?
This question already has an answer here:
- How do I update a GitHub forked repository? 18 answers
I forked a repo on github and changed a couple of things. The original repo has committed a couple of things. How can I update my fork without re-forking and undoing all my changes?
原文:https://stackoverflow.com/questions/31096236
更新时间:2022-05-16 11:05
最满意答案
使用返回相应类的实例的工厂函数。
def makeCounter(seq): if hasOnlyHashables(seq): return OptimizedCounter(seq) else: return MyCounter(seq)
Use a factory function that returns an instance of the appropriate class.
def makeCounter(seq): if hasOnlyHashables(seq): return OptimizedCounter(seq) else: return MyCounter(seq)
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
正如上面提到的Ether,你应该有一个工厂方法来完成这个任务。 我喜欢将工厂方法放在一个单独的包/类中,而不是它生成的东西通常这是一个没有属性或构造函数的虚拟类,但是如果你想做一些事情,比如跟踪你做了什么,你可以创建一个实际的工厂对象。 package MyFile::Factory; sub make_file_object { my $class = shift; my $filepath = shift; my $type = $class->determine_file_ ...
-
你不能分配给$this ,你不能从构造函数返回任何东西。 You can't assign to $this and you cannot return anything from a constructor.
-
了解static nested class和instance nested class之间的区别。 其他一些SO问题也一样。 短期内容:用静态声明你的内部EmptySea类,然后阅读/理解为什么 - 简而言之,在没有static的情况下,不能在Ship实例的上下文之外创建EmptySea实例。 Learn about the difference between a static nested class and an instance nested class. Some other SO questio ...
-
您的解决方案是功能性的,并且包含一些松散的MATLAB类型以实现您想要的。 但是,获得干净且结构化的OOP可能需要丢失一些您想要的功能。 同时,避免代码重复的最佳选择是模板化/通用容器类,但目前MATLAB不支持这些类。 您的代码反映了构造函数中构建数组的MATLAB文档,并依赖于MATLAB作为一种松散类型的语言,使您能够将对象转换为对象数组而不会出现问题。 利用MATLAB强大而灵活的功能确实会引入一些组织问题,并可能会破坏您在干净的面向对象代码方面的努力。 问题开始是因为MyBaseClass构造函数 ...
-
使用返回相应类的实例的工厂函数。 def makeCounter(seq): if hasOnlyHashables(seq): return OptimizedCounter(seq) else: return MyCounter(seq) Use a factory function that returns an instance of the appropriate class. def makeCounter(seq): if hasOnl ...
-
C#与此没有任何确切的等价物。 但是,您可以通过使用这样的泛型类型约束来解决这个问题: public class MyBaseClass { public string Name { get; private set; } public static T GimmeOne
(string name) where T : MyBaseClass, new() { return new T() { Name = name }; } protecte ... -
是否有可能从其父类的构造函数中返回一个子类(Is it possible to return a child class from the constructor of its parent class)[2023-03-26]
不,没有办法,但......这听起来像是一个工厂模式实现为静态方法: class ParentClass { // "disable" ctor for public use but // allow for children protected ParentClass() { } public static ParentClass CreateInstance(int @case) { if(@case==1) retur ... -
Java子类构造函数(Java subclass constructor)[2023-07-18]
你可以在调用super()之后进行检查并抛出异常。 如果在构造函数期间的任何时候抛出异常,则该对象将被丢弃并且不可用于呼叫者。 如果您担心效率问题,可以编写一个静态方法来执行检查并引发异常,如下所示: super((byte) 0 , doChecks(data)); 如果没有问题, doChecks会返回data ,否则会抛出异常。 You can do the check and throw the exception after the call to super(). If an exceptio ...