@BernardMeurer to be fair, you got downvoted not just because "it isn't code review" but also because originally your answer didnt' address the question.
@Quill what does knowing how to optimize code written in a language nobody uses actually teach you besides things that you can't apply to any real code?
Uncaught ReferenceError: N is not defined(…)(anonymous function) @ VM1435:2InjectedScript._evaluateOn @ VM1434:875InjectedScript._evaluateAndWrap @ VM1434:808InjectedScript.evaluate @ VM1434:664
I have this tiny library for building HTML pages in Java code:
HtmlViewComponent.java
package net.coderodde.html.view;
/**
* This abstract class defines the API for logical HTML view components, that
* may consist of other view components;
*
* @author Rodion "rodde" Efremov
* @version 1...
This program downloads a Code Review HTML file and parses it.
Could you review my program?
Main.java
import java.net.URL;
public class Main {
public static void main(String[] args) throws Exception {
final String site1 = "http://codereview.stackexchange.com/questions/";
St...
I have a view that has two textfields in the top of the view and a tableview in the bottom half. If I add a touch gesture recognizer to the view, table row selection no longer works. One of the textfields uses the default keyboards, but the other uses a decimal pad. I could use return or "Done" i...
Hellо, I am a compiler.
I just scanned thousands of lines of code while you were reading this sentence. I browsed through millions of possibilities of optimizing a single line of yours using hundreds of different optimization techniques based on a vast amount of academic research that you would ...
@nhgrif okay, what does ! mean in Swift? I guess ? means "nullable" or similar. I appreciate I could google this but you'd probably explain it more succinctly.
> I want to generate statistical reports and, I have many deferent where clauses so the function became so long I did many refactoring but it is not enough can some one help me with some technics that these technic make the function short and readable
And even in that one occasion, I'm going to make the case that it's not really acceptable, but Apple is the only one that can fix it to do anything else so we just have to deal with it.
I want to generate statistical reports and, I have many deferent where clauses so the function became so long I did many refactoring but it is not enough can some one help me with some technics that these technic make the function short and readable
public static function allRejUserByProv($prov ...
You do this to allow a variable to be nil, but know that it's safe-ish to do this because in practice it never should be nil.
In reality, there is exactly one occasion on which it is acceptable, and it's only acceptable there because it's up to Apple to fix and we can't do anything else about it until then.
@Mat'sMug Because in Swift, every non-optional property must have a value before initialization is complete. Having implicitly unwrapped allows you to let some things be nil while not forcing you to write the unwrap code all over the place.
@nhgrif So an example might be using property injection (for whatever reason) where even though it can theoretically be null you know that in practice it won't be?
And again, the only place it's really acceptable is with @IBOutlets, which don't get hooked up during initialization, but in practice are hooked up before you ever use the code. It has to do with whatever magic Apple uses to hook UI elements to properties at run time.
class ProperPerson {
let firstName: String
let lastName: String
init(firstName: String, lastName: String) {
self.firstName = firstName
self.lastName = lastName
}
}
^ this is proper Swift.
@BernardMeurer I'm not sure that you need Xcode, but you do need to be on OS X to develop for iOS. And using anything other than Xcode for iOS would be very silly.
@BernardMeurer Get a job with a company that provides MacBook Pros as your development machine. Tons of companies do unless you're developing .NET stuff (and even then, the .NET devs at the company I work for use MBP machines with bootcamp or something)
and self is like a this. would it be legal to prefix the firstName field with, say, an underscore, and then do _firstName = firstName (almost typed a semicolon) in the init method?
@Mat'sMug A required initializer must be implemented or inherited by all subclasses. Swift initializers are not guaranteed to be inherited. A convenience initializer cannot call to super.init, but must call a designated initializer on the class (or another convenience initializer which eventually chains down to a designated initializer). Designated initializers must call to a super class initializer (if you're inheriting from a class).
@Mat'sMug Yes. It'd be legal, but we wouldn't want to make our public properties prefixed with an underscore