草庐IT

Any-Integer

全部标签

android - 使用 kotlin 在 Android 单元测试中模拟对象 - any() 给出 null

我正在尝试测试我的类,我需要模拟一个static类。我的代码如下:PowerMockito.mockStatic(ToolTipUtil::class.java)PowerMockito.`when`(ToolTipUtil.wasToolTipShown(any(Context::class.java),"")).thenReturn(true)valcontext=mock(Context::class.java)presenter.onResume(context)verify(view).setMenuButtonShown(eq(false))但是在第二行它会抛出一个错误:"

kotlin - 在 Kotlin 中声明 Byte 会出现编译时错误 'The integer literal does not conform to the expected type Byte'

正如在0xFF0000FFAnintegerliteraldoesnotconformtotheexpectedtypekotlin.Int中看到的另一个问题我将值0xFF声明为字节valb:Byte=0xFF接收整数文字不符合预期的字节类型编译错误因为我知道kotlin.Byteissignedbyte如何在Kotlin中用0x00声明字节-0xFF无符号字节就像.net字节b=0xFF?..如果您想要即时编译器进行测试和回答:rextester,try.kotlinlang.org 最佳答案 Kotlin不会自动在数字类型之间进

Java/Kotlin 等效于 Swift [字符串 : [String : Any]]

在Kotlin或Java语言中,Swift中的[String:[String:Any]]是什么?我需要从数据库中检索如下结构:Key:Key:ValueKey:ValueKey:ValueKey:Key:ValueKey:ValueKey:Value 最佳答案 这个结构可以用Map>表示.创建此类类型的Kotlin代码:valfromDb:Map>=mapOf("Key1"tomapOf("KeyA"to"Value","KeyB"to"Value"),"Key2"tomapOf("KeyC"to"Value","KeyD"to"V

generics - Kotlin 泛型中 "*"和 "Any"之间的区别

我不确定我是否完全理解SomeGeneric之间的区别和SomeGeneric.我认为*代表任何东西(通配符)和Any表示ALL对象继承自的对象。所以看起来它们应该是一样的,但是它们是吗? 最佳答案 想一想starprojection可能会有所帮助不仅可以表示任何类型,还可以表示一些您不知道到底是什么的固定类型。例如,类型MutableList表示something的列表(您不知Prop体是什么)。因此,如果您尝试将某些内容添加到此列表中,您将不会成功。可能是String的列表s,或Int的列表s,或其他东西的列表。编译器根本不允许

list - Kotlin:如何使用列表强制转换:未经检查的强制转换:kotlin.collections.List<Kotlin.Any?> 到 kotlin.colletions.List<Waypoint>

我想写一个函数来返回List中的每一项。那不是第一个或最后一个项目(通过点)。该函数得到一个通用的List作为输入。仅当列表元素的类型为Waypoint时才应返回结果:fungetViaPoints(list:List):List?{list.forEach{if(it!isWaypoint)returnnull}valwaypointList=listas?List?:returnnullreturnwaypointList.filter{waypointList.indexOf(it)!=0&&waypointList.indexOf(it)!=waypointList.lastI

docker-compose : any way to specify a redis. conf文件中的Redis?

我的Redis容器在我的docker_compose.yml中定义为标准镜像redis:image:redisports:-"6379"我猜它使用的是标准设置,例如在本地主机上绑定(bind)到Redis。我需要绑定(bind)到0.0.0.0,有没有办法在本地添加一个redis.conf文件来改变绑定(bind),让docker-compose来使用?感谢您的任何技巧... 最佳答案 是的。只需使用卷将您的redis.conf安装在默认值上:redis:image:redisvolumes:-./redis.conf:/usr/l

forms - meteor /MongoDB : insert integer instead of string on form submit

我正在阅读David在http://meteortips.com/上的Meteor教程。.如何在表单提交时插入整数而不是字符串?我认为以下行需要澄清它是一个整数,但我不确定如何。varplayerScoreVar=event.target.playerScore.value;这是我的全部代码。Template.addPlayerForm.events({'submitform':function(event){event.preventDefault();varplayerNameVar=event.target.playerName.value;varplayerScoreVar=e

javascript - MongoDB native : is there any difference between toString and toHexString methods?

我将Node.jsv0.12.0与MongoDB驱动程序v1.4.34一起使用。那么,使用toString和toHexString方法将ObjectID转换为String有什么区别吗? 最佳答案 toHexString方法以24字节十六进制字符串表示形式返回ObjectIDid。//CreateanewObjectIDvarobjectId=newObjectID();//Verifythatthehexstringis24characterslongassert.equal(24,objectId.toHexString().le

security - MongoDB "userAdminAnyDatabase"用户无法管理 "any database"中的用户。为什么?

这是一个userAdmin与userAdminAnyDatabase的问题。在system.users我有以下用户(密码1234两个):>db.system.users.find(){"_id":ObjectId("52a976cb7851682aa44d6d4d"),"user":"admin_one","pwd":"884f516cf308a4c6a75bbc5a0a00807b","roles":["userAdmin","dbAdmin"]}{"_id":ObjectId("52a97c697851682aa44d6d4f"),"user":"admin_two","pwd":

php - Symfony2 MoneyType 与除数 : integer conversion leads to wrong database values

我们将所有与货币相关的值都以美分的形式存储在我们的数据库中(ODM但ORM的行为可能相同)。我们使用MoneyType将面向用户的值(12,34€)转换为他们的美分表示(1234c)。typicalfloatprecision这里出现了问题:由于精度不足,许多情况下会产生舍入误差,而这些误差仅在调试时可见。MoneyType会将传入的字符串转换为可能不精确的float("1765"=>1764.9999999998)。一旦你坚持这些值(value)观,事情就会变得糟糕:classPrice{/***@varint*@MongoDB\Field(type="int")**/protect