dcalsky

dcalsky

V2EX 第 150170 号会员,加入于 2015-12-06 11:26:02 +08:00
不要告诉别人我又在逛v2
根据 dcalsky 的设置,主题列表被隐藏
二手交易 相关的信息,包括已关闭的交易,不会被隐藏
dcalsky 最近回复了
16 天前
回复了 dwu8555 创建的主题 旅行 能一个人坐 K3 火车去俄罗斯玩吗?
@mangoDB 不搞了
23 天前
回复了 dwu8555 创建的主题 旅行 能一个人坐 K3 火车去俄罗斯玩吗?
昨夜见军帖,可汗...
37 天前
回复了 naturekingfree 创建的主题 Flutter flutter 开发用什么工具
根据我的观察,flutter 还是用 vscode 写的人多
37 天前
回复了 naturekingfree 创建的主题 Flutter flutter 开发用什么工具
没汉化?你的 java 是基于易语言引擎特供版吗?
@body007 这样是不行的,function type 是 unique ,不能通过断言比较。
建议用 interface 的实现来判断,如果强行判断的话,那本质是比较 function signature 。拿到 test 和 fn 的 type 然后比较即可。

```go

type fn func(ctx context.Context) []string

func test(ctx context.Context) []string {
return []string{"1"}
}

func main() {
if matchFunctionSignature(reflect.TypeOf(test), reflect.TypeOf((fn)(nil))) {
fmt.Println(true)
} else {
fmt.Println(false)
}
}

func matchFunctionSignature(a, b reflect.Type) bool {
if a.Kind() != reflect.Func || b.Kind() != reflect.Func {
return false
}

if a.NumIn() != b.NumIn() || a.NumOut() != b.NumOut() {
return false
}

for i := 0; i < a.NumIn(); i++ {
if a.In(i) != b.In(i) {
return false
}
}

for i := 0; i < a.NumOut(); i++ {
if a.Out(i) != b.Out(i) {
return false
}
}
return true
}

```
51 天前
回复了 undertheros3 创建的主题 职场话题 今天写了一些很优雅的代码😄
quick_sort = lambda arr: [] if not arr else quick_sort([val for val in arr[1:] if val <= arr[0]]) + [arr[0]] + quick_sort([val for val in arr[1:] if val > arr[0]])
53 天前
回复了 ssgooglg 创建的主题 随想 同学考博招 16 人排名 17
吃了学历的亏,也中了学历的毒。真心为他感觉难受
53 天前
回复了 ssgooglg 创建的主题 随想 同学考博招 16 人排名 17
到硕士差不多了,再往上读无论走哪条路线,他的第一学历都会成为他的短板。

虽然很残酷,但是现实就是很现实。
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1849 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 00:25 · PVG 08:25 · LAX 17:25 · JFK 20:25
Developed with CodeLauncher
♥ Do have faith in what you're doing.