当我尝试创建扩展函数以设置布尔值true或false时,如下所示.
Boolean.setTrue(){
this = true
}
Boolean.setFalse(){
this = false
}
Run Code Online (Sandbox Code Playgroud)
它表示预期变量.如何实现这一目标.
我在dotm模板中有一个非常简单的Word子句:
Sub YHelloThar(msg As String)
MsgBox (msg)
End Sub
Run Code Online (Sandbox Code Playgroud)
然后我有一个Excel子:
Sub CallWordSub()
Dim wdApp As Word.Application
Dim newDoc As Word.Document
'Word template location
strFile = "C:\Some\Folder\MyWordDoc.dotm"
'Get or create Word application
Set wdApp = GetObject(, "Word.Application")
If wdApp Is Nothing Then
Set wdApp = CreateObject("Word.Application")
End If
'Create new Word doc from template
Set newDoc= wdApp.Documents.Add(strFile)
'Call the YHelloThar sub from the word doc
Call wdApp.Run(strFile & "!YHelloThar", "Hello")
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
最后一行给出了"运行时错误'438':对象不支持此属性或方法."
我不确定我做错了什么 - 我查找的所有内容都表明这是从不同应用程序调用subs的正确方法.
此外,如果我将最后一行更改为无参数调用,它会突然正常工作.
我在spek
试图找到测试时遇到了崩溃.我尝试过很多不同的版本和样本配置.我从命令行运行.Gradle 4.0,mac osx.任何帮助,将不胜感激!
这是错误:
WARNING: TestEngine with ID 'spek' failed to discover tests
java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.findAllClassesInClasspathRoot(Ljava/nio/file/Path;Ljava/util/function/Predicate;Ljava/util/function/Predicate;)Ljava/util/List;
at org.jetbrains.spek.engine.SpekTestEngine.resolveSpecs(SpekTestEngine.kt:66)
at org.jetbrains.spek.engine.SpekTestEngine.discover(SpekTestEngine.kt:50)
at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:130)
at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:117)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
at org.junit.platform.launcher.Launcher.execute(Launcher.java:96)
at org.junit.platform.console.tasks.ConsoleTestExecutor.executeTests(ConsoleTestExecutor.java:65)
at org.junit.platform.console.tasks.ConsoleTestExecutor.lambda$execute$0(ConsoleTestExecutor.java:57)
at org.junit.platform.console.tasks.CustomContextClassLoaderExecutor.invoke(CustomContextClassLoaderExecutor.java:33)
at org.junit.platform.console.tasks.ConsoleTestExecutor.execute(ConsoleTestExecutor.java:57)
at org.junit.platform.console.ConsoleLauncher.executeTests(ConsoleLauncher.java:85)
at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:75)
at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:48)
at org.junit.platform.console.ConsoleLauncher.main(ConsoleLauncher.java:40)
Run Code Online (Sandbox Code Playgroud)
这是我当前的build.gradle:
buildscript {
repositories {
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$project.ext.kotlinVersion"
}
}
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'idea'
apply plugin: 'kotlin'
apply plugin: 'java'
junitPlatform {
filters …
Run Code Online (Sandbox Code Playgroud) 我们将Java文件转换为Kotlin文件,然后编译为类文件.生成的类比原始Java类文件大.在Kotlin类文件中,我们在每个类中都找到了元数据.为什么Kotlin会存储这些元数据?
我想在dart中声明一个字段,并且仅覆盖getter的功能,但是我不确定如何/是否可行。
class Pony {
String ponyGreeting;
String ponyName;
Pony(this.ponyGreeting, this.ponyName);
String get ponyGreeting => "$ponyGreeting I'm $ponyName!";
}
Run Code Online (Sandbox Code Playgroud)
但是,这会导致错误,因为我已经定义了“ ponyGreeting”。我不能仅仅摆脱ponyGreeting字段,因为我想使用构造函数来设置它,如果我创建了一个setter,我将不得不在某个地方设置该值,而我实际上并不需要多余的属性。
我正在制作一个解决数学表达式的程序,例如2 + 2.我可以设置一个等于这样的整数:
val input = "2+2"
input.toInt()
Run Code Online (Sandbox Code Playgroud)