我正在使用Subversion来检查OSX上的文件.我将EDITOR变量配置为MacVim
我的.profile包括:
export EDITOR=/Applications/MacVim/mvim
Run Code Online (Sandbox Code Playgroud)
当我使用-m选项(svn ci somefile)签入时,MacVim会启动,但随后Subversion会立即显示:
Log message unchanged or not specified
(a)bort, (c)ontinue, (e)dit:
Run Code Online (Sandbox Code Playgroud)
在我有机会在MacVim中保存我的日志消息之前,它会显示此信息.
有没有办法让SVN使用MacVim作为日志消息编辑器?
我在一本书中找到了这个代码,并在Netbeans中执行了它:
boolean b = false;
if(b = true) {
System.out.println("true");
} else {
System.out.println("false");
}
Run Code Online (Sandbox Code Playgroud)
我只是不明白为什么这段代码的输出是真的,请有人赐教,谢谢.
我有一个Java类,它位于src/java外部JAR的引用类中.我将JAR文件复制到lib目录中.当我使用运行应用程序时,grails run-app我得到一个错误,它无法找到导入的类.
将JAR放入Grails项目的正确位置是什么?是否有一些特殊的命令让Grails识别新添加的JAR文件?
我在OS X上运行带有Java 1.6.0_29的Grails 2.0.0.
后续行动: JAR的问题来自Apache HttpComponents.进一步来说:
commons-codec-1.4.jar
commons-logging-1.1.1.jar
httpclient-4.1.2.jar
httpclient-cache-4.1.2.jar
httpcore-4.1.2.jar
httpmime-4.1.2.jar
Run Code Online (Sandbox Code Playgroud)
其中的类文件被编译为Java 1.3,这应该不是问题.
~/temp/org/apache/http $ file HttpResponse.class
HttpResponse.class: compiled Java class data, version 47.0 (Java 1.3)
Run Code Online (Sandbox Code Playgroud) 下面的代码调整位图大小并保持宽高比.我想知道是否有更有效的调整大小的方法,因为我知道我正在编写已经在android API中可用的代码.
private Bitmap resizeImage(Bitmap bitmap, int newSize){
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int newWidth = 0;
int newHeight = 0;
if(width > height){
newWidth = newSize;
newHeight = (newSize * height)/width;
} else if(width < height){
newHeight = newSize;
newWidth = (newSize * width)/height;
} else if (width == height){
newHeight = newSize;
newWidth = newSize;
}
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix(); …Run Code Online (Sandbox Code Playgroud) 鉴于此示例代码:
Runnable r = new Runnable() {
public void run() {
System.out.print("Cat");
}
};
Thread t = new Thread(r) {
public void run() {
System.out.print("Dog");
}
};
t.start();
Run Code Online (Sandbox Code Playgroud)
为什么输出狗而不是猫?
我有一个不可变对象,它是使用组件映射的Hibernate持久化对象的成员.示例,PinDrop对应于一个表,其中包含一个类型为immutable的字段Point:
public class PinDrop {
private String name;
private Point location;
// Getters and setters for name and location
}
// Immutable Point
public class Point {
private final double x;
private final double y;
// Getters for x and y, no setters
}
Run Code Online (Sandbox Code Playgroud)
在我的PinDrop.hbm.xml:
<property name="name" column="name" type="string"/>
<component name="location" class="Point>
<property name="x" column="location_x" type="double"/>
<property name="y" column="location_y" type="double"/>
</component>
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为在运行时Hibernate抱怨Point没有set x和for y.有没有办法使用不可变对象作为Hibernate持久对象的组件?
后续行动:我没有使用注释,而是使用注释hbm.xml.无论是mutable也不 …
考虑这个配置MKMapView地图类型的示例.是否应该完成viewDidLoad()
override func viewDidLoad() {
super.viewDidLoad()
mapView.mapType = MKMapType.Hybrid
}
Run Code Online (Sandbox Code Playgroud)
还是在var didSet?
@IBOutlet weak var mapView: MKMapView! {
didSet {
mapView.mapType = MKMapType.Hybrid
}
}
Run Code Online (Sandbox Code Playgroud)
两者都有效,Swift首选的方式是什么?
如何创建泛型数组?例:
struct Thing<Any> {
}
let intThing = Thing<Int>()
let stringThing = Thing<String>()
// This line doesn't compile
// Cannot convert value of type 'Thing<Int>' to expected type 'Thing'
let things: [Thing] = [intThing, stringThing]
Run Code Online (Sandbox Code Playgroud)
如何声明任何类型的泛型(类似于Thing<?>or Thing<Any>)?
我有本地构建的 C 库(.h和.a文件),我想将其包含在基于 Swift 的 CocoaPods pod 中。如何配置 podspec 以依赖于.a文件和module.map?对于普通的非 CocoaPods Xcode 项目,我只需将其拖入包含的目录include,lib然后添加一个module.map. 使用 CocoaPods 我无法执行此操作,因为pod install会覆盖 Xcode 项目文件。s.library不起作用,因为静态库没有托管在任何地方。我尝试过s.vendored_libraries,但module.mapXcode 仍然未知,最终结果是import foo我的 Swift 文件出现错误。
编辑:我尝试使用preserve_paths,vendored_libraries并xcconfig如此处回答。问题仍然是如何从 Swift 导入模块。
编辑 2:我还尝试使用module_map指向我的module.map文件(如此处记录),但遗憾的是 CocoaPods 1.1.1 崩溃了 ( [!] Oh no, an error occurred.)。
Swift 支持解构。
func pair() -> (String, String)
let (first, second) = pair()
Run Code Online (Sandbox Code Playgroud)
有没有办法将可选元组解构为单个可选值?
func maybePair() -> (String, String)?
let (maybeFirst, maybeSecond) = maybePair()
Run Code Online (Sandbox Code Playgroud)
这样maybeFirst和maybeSecond是可选字符串 ( String?)。