« first day (838 days earlier)      last day (3181 days later) » 

12:00 AM
This is old as f*ck
Duga wasn't around then
 
RELOAD!
 
interrupt
 
There are 1478 unanswered questions (94.3792% answered)
 
@Malachi Edit this to interrupt
And you get free stars
 
anyone have a good way to wait while a file is being created?
 
12:01 AM
Well @Quill, there are questions that need answers according to @Duga, but I've been having trouble finding something interesting to answer lately.
 
Time to eat
 
@Malachi depends on how it's being created.
 
Why would I wait? It takes longer to start the wait than for the file to be created...
 
@Malachi Don't let it burn!
 
File.Create.
I will continue this in a minute, my Lady is getting irritated with me, food is getting cold
 
12:03 AM
Supper is going on here too.
 
@Quill 404 tag not found. And thank God.
 
0
Q: Angular directives

Amanda Ferrari'use strict'; var eventSidebarDirective = { /** * Initialize sidebar directive and return the link * calling all nested methods. * */ init: function() { return { link: function(scope) { scope.$watch('events', function() { ...

 
12:26 AM
@Mat'sMug /*phew/*
 
12:38 AM
okay I am back
she wasn't even irritated
@RubberDuck File.Create
 
0
Q: Python 2D convolution without forcing periodic boundaries

neither-norI'm modeling a disease problem where each individual in a 2D landscape has a transmissibility described by a (radial basis) kernel function. My goal is to convolve the kernel with the population density such that the output captures the transmission risks across the landscape. I performed the co...

0
Q: Basic Sign Up Method, Testable and With Try/Catch

JonI am learning how to implement testing and try/catch statements into my code. I have a laravel application with the following method. I am looking for advice on where I should add in try/catch statements and what phpunit unit-test(s) I would create to ensure this is functioning properly. Tips on ...

 
1:13 AM
0
Q: Changing attributes in Django Objects outside of iteration

BarFooBarI'm adding three attributes to a Django QuerySet that represents a hierarchical tree structure: a display_name which is added to all objects the id of the object's parent (or immediate_parent) which is added to all objects based on a condition a boolean is_parent field that should be added if a...

 
Modifying the parent object I created does not modify the original QuerySet. I figured out a way to do it by iterating over the QuerySet 3 times, but it's not pretty. If you have suggestions I'd love to see them on the (code review question)[codereview.stackexchange.com/questions/101426/… that I just posted. — BarFooBar 22 secs ago
 
0
Q: Finding the order of sorting of an array

In78I am finding the order of sorting of an array. The code works but can it be made better especially the return values of the function findSortOrder. #include <stdio.h> #include <stdlib.h> // Returns 0 for unsorted, 1 for sorted in increasing order, 2 for sorted in decreasing order int findSortOr...

 
1:31 AM
The reviews are much more active now. Before I could just clear them periodically, and would get several a day.
Now I just had to install @Malachi's user script to get enough first posts to get my badge...
 
@Hosch250 give some thanks to @SimonAndréForsberg, he gave me the base. I altered his script a bit.
I didn't have to use thread.wait or a singleton for my HighScoresManager, I just had to stop using File and use a XmlWriter instead
 
1:53 AM
@Malachi It doesn't work.
I just found something in the close vote queue that I wasn't told about.
Do I have to leave the tab open, or something?
 
0
Q: Finding the postion of a substring in a string

AaronI am given two strings and return the position if in the larger string the smaller string is found. If not I am returning -1 for position. Any suggestions for improving my code. using System; using System.Collections.Generic; using System.Linq; namespace Reverse { class MainClass { ...

 
Just posted a long and more complete answer to an old question with answers I only just today realized were incomplete:
1
A: Swift: Class does not implement its superclass's required members

nhgrifThere are two absolutely crucial pieces of Swift-specific information that are existing from the existing answers which I think help clear this up completely. If a protocol specifies an initializer as a required method, that initializer must be marked using Swift's required keyword. Swift has a...

 
2:16 AM
@Hosch250 oh yeah, you have to leave it open to that review page
sorry. I thought I put it in there somewhere
how do I disconnect a fork?
 
0
Q: Java Code program for student info system

Jessamublic class Jessa { public static void main(String[] args) { BufferedReader buff = new BufferedReader(new InputStreamReader(System.in)); StudentRecord[] arrStudentRecord = new StudentRecord[10]; String select = null; int x=0; //=============DECLARATION OF VARIABLES=======...

 
@CaptainObvious ?
 
what license should I add to my repo?
 
...don't ask the duck. He's got strong opinions about FOSS licensing.
 
think I will use MIT this time around? IDK
I will add it later or something
 
2:29 AM
@CaptainObvious lol
 
I like MIT. It's unrestrictive.
It was nice to review some code for a change. Pretty sure OP isn't gonna like the answer though.
> Throw your code away and use string.IndexOf()
 
well, why not?!
I'd even add a comment:
// rule #1: know your tools
> return the position if in the larger string the smaller string is found.
define "the position"
                while (stringOne [j] == stringTwo [i]) {
                    j++;
                    i++;
                    if (stringOne.Length == j) {
                        return position;
                    }
is that "starting position", or "ending position"?
nah
nevermind
hey @200_success
 
That loop does bug me, but it was a phonie. I'd want to look at that in VS.
 
@RubberDuck I went with a GNU license
TFB
see you all tomorrow
 
night!
@RubberDuck I like phony answers :)
> bah-dum-tish
 
2:47 AM
I think you might want this on code review... — Zizouz212 21 secs ago
 
@Mat'sMug What's up?
 
big day on MSE today :)
Thank you! This is the announcement that should have been posted. — 200_success 7 hours ago
 
There's still hope.
 
there's always hope.
what's left at the bottom of Pandora's box?
hope
 
Vogel has made some really good points.
 
2:55 AM
his answer was excellent
I don't understand why it got so many downvotes
 
His comment was even better:
If it happened once in the past by accident, then what we're asking for couldn't possibly be that hard to implement.
 
> It wasn't an unobserved side-effect of my performance refactorings in any way, so the current build I'm frantically pushing out will probably have no effect except for coincidence.
 
@200_success Why is his/her name "Vogel612's Shadow"?
 
but to implement correctly might be a different thing
@SirPython because his MSE profile has it that way
I could rename my MSE profile to Dark Side of the Mug
 
3:19 AM
This should go to CodeReview. — Xufox 38 secs ago
I've voted to close as off-topic / "too broad", as code reviews as off-topic on Stack Overflow. I've also moderator-flagged for the question to be migrated over to Code Review. — Mat's Mug just now
This seems way more complicated than it should be. Once migrated to codereview, lots of things could be improved in this. — jfriend00 32 secs ago
 
3:43 AM
0
Q: Salsa20 stream cipher implementation

scotttybI have implemented the Salsa20 stream cipher as an ICryptoTransform. It runs fairly fast and has successfully encrypted and decrypted all of my tests. I would mostly like the Salsa20 algorithm to be reviewed (since there are very few reference implementations in C# out there), to make sure I have...

 
@CaptainObvious 2nd post from that user. 1st post was an answer, on that C# string question
 
Thanks guys. Will post it in code review now. — Him 9 secs ago
Requests for critiquesof working code is better suited to Code Review. — wwii 11 secs ago
 
4:02 AM
@Duga cross-post prevented by a split second!
@DevSolar in Soviet Russia, man bats you! — Daft 11 hours ago
Holy Batmen, Batman; there's two Batmans!Mazura 21 hours ago
 
4:37 AM
With the code added in Rev 3, this question is now suitable for Code Review. — 200_success 5 secs ago
 
I hit a very peculiar bug in VSDiagnostics.
I'm going to bed now, I'll try to fix tomorrow.
 
night!
 
Night.
If you need help with RD, let me know.
 
sure
 
Classes are starting to go up, so I'm probably going to help get this release of VSDiagnostics out, then not be as available - time to post CR questions and refactor code.
(And work in the First Posts queue - 90 to go, and the user script doesn't seem to work even when I do have the tab open, @Malachi.)
Have fun!
 
5:28 AM
monking @all
 
@chillworld monking!
 
nice, green but that's always with 0 tests ;)
 
that's the Rubberduck 2.0 test explorer, in the WPF designer :)
the white part is going to be a tree view
down with the datagridview. grids are so 5-years-ago.
besides, if we're going to have a WPF UI, might as well leverage the almighty databindings!
 
rubber duck seems quit big already
 
yeah... too big for the architecture it was built on. it's undergoing major refactorings right now, so we can keep it growing healthily
 
5:41 AM
I'm sure you guy's can pull it to the right track
 
I hope so :)
 
just looking at this one :
1
Q: Event Aggregator Pattern Decoupling

AndyRoidI have an Android application that is using an EventBus architecture with publishing and subscribing events. Usually this is from Controllers (Activities) to a "Manager" class that handles all the subscriptions. Here is an example: Controller Class public abstract class EventBusActivity extend...

nice question, did see a very minor flaw (to minor to answer just for that)
 
ooh pictures
 
but seems the OP doesn't have patience
indeed :)
brb break :)
 
anyway, waaaay past TTGTB here
'night!
 
6:05 AM
night @Mat'sMug
 
6:24 AM
0
Q: Optimising the python code

MohitThis code is according to this problem:- Here I know its an open challenge, but it is not for any job related coding, and I have also partially solved the problem and just need an optimized code. My code:- #checks if the input 2 points, along with 3rd point as Origin, forms a right angle tria...

0
Q: Security issue in java beans

deeiipI am fairly new to java beans. Can you point out any problem here, public class LoginDao { public static boolean validate(LoginBean bean){ boolean status=false; try{ Connection con=ConnectionProvider.getCon(); // make sure table name is correct PreparedStatement ps=con.prepareStateme...

 
6:42 AM
0
Q: Function that reorders the columns of a matrix in Matlab

Ryan The objective: Given an m by n matrix, I have written a function in Matlab that reorders the columns of the matrix to output: [Linearly independent columns; Other/Redundant columns]. So basically, it just pushes the redundant columns to the end of the matrix. Here is my attempt at the code ( wh...

0
Q: Pass a String argument to a function in order to prevent redundant code?

user3475602I have got used to pass an argument type to several JavaScript functions in order to prevent redundant code. For instance: function handleData (type) { if (type == 'type1') { //... do something type1 specific } else if (type == 'type2') { //... do something type2 specifi...

 
7:11 AM
wow, never saw such a smelly code as in this one : codereview.stackexchange.com/questions/101441/…
never close a connection, preparedstatement or resultset.
This application will hang as soon 10 people sign in (there he have his requirement ^^)
 
I'd be willing to reopen it for you. Your choice.
If so, please fix up the question.
 
0
Q: Python pattern Matching is slow

Vignesh KalaiThis is my code: #Importing modules import requests import re import sys import pyodbc import json import datetime import random import time import ftplib import traceback #loading regex files start_time_split=datetime.datetime.now() json_data=open('server_details.json') server_details = json.lo...

 
7:42 AM
This should go in CodeReviewSebastian 54 secs ago
 
8:18 AM
0
Q: Does python's pycompile or compileall handle dependencies?

user81608When using pycompile or compileall to make a py into a pyc, does it remove dependencies so that the user only needs to have the python interpreter, but not the libraries? As a side note: what else is done during compilation other that shortening the code?

 
Monking
 
8:31 AM
@CaptainObvious No code, blatantly off-topic, 2 more VTC.
@chillworld His user is hardcoded, doesn't look like it will do what he wants it to do.
 
0
Q: Optimising "Find position of String in Dimension of Array" Function

ZakPurpose of the function: Given an array and a string and bounds within which to search, find the position of the string within those bounds. What I want to optimise: If possible, I want to re-design the function so that it doesn't have 10 optional arguments, some of which are not actually opti...

 
@mast it isn't the user but that's the table name ^^
@200_success That's the OP his task, he must want it and take action in order to get a review. ;)
 
9:11 AM
Monking ^.^
2
 
Monking
@Malachi 373 rep for you to reach 20k. Go for it !
 
9:39 AM
monking
 
I'm guessing you are asking if we would review your code to see if you adhere to the principles of SOLID and DRY "the right way" or give tips how to better follow those principles. That question might be better asked on codereview.stackexchange.comBuurman 46 secs ago
 
9:57 AM
monking
 
monking @DJanssens
 
0
Q: DDA Line Drawing Algorithm

anonymousI am using WinBGIm. #include <iostream> #include <cmath> #include "graphics.h" void Swap(double &a, double &b) { double x = a; a = b; b = x; } double Round(double number) { return (number >= 0) ? (int)(number + 0.5) : (int)(number - 0.5); } void PlotPixel(int x, int y, int co...

 
0
Q: MVC Creating more flexible views

yoger I've started with MVC recently, trying to learn how the Views work, recall some html knowledge and introduce myself to java script, jquery and ajax without being punched in the face. Started with expanding standard Edit form that Visual Studio generated for me. I've got Employee that always ha...

 
10:20 AM
Monking
 
10:32 AM
0
Q: Generic method to pass lambda expressions performed on DTO's to Entity Framework

afmThe following are generic methods that I use to perform lambda queries on DTO objects. The main method applies the expression to entities and returns DTO objects mapped from the entities (entities returned from the expression being executed on the database). I am sure that this could be optimise...

0
Q: Anonymous function to Javascript Object Literal refactoring

Cosmin AncaI'm trying to refactor some code I wrote months ago when I used to use lots of anonymous functions. The way I'm trying to do it now is by taking all those functions and rewrite them within Object Literal Pattern. I'm new to this kind of pattern and I would like to know if I'm doing it right, wha...

 
11:01 AM
Monking
 
Greetings
@CaptainObvious Seems like a request to change code?
 
0
Q: python ANSI colors cross platform

Deeok, trying to write for both NT and posix (my two usual platforms) and have come up with the code below. The clrs code I refer to is apparently from blender build scripts, I discovered it on this SO post. They called the class bcolors but I wanted to reduce clutter so I renamed it. But the main ...

 
@CaptainObvious Deserves some German Overnegeneering?
 
Monking
 
Greetings
 
11:10 AM
wow I may even cap 2 times in a row on MSE..
 
@IsmaelMiguel Congratulations, you've written « Greetings » more than 200 times in this room :o
 
@Vogel612 MSE?
@Morwenn How do you know?
 
Need help capping?
 
@IsmaelMiguel You can search for messages posted by a given user.
 
11:11 AM
@IsmaelMiguel doubt it.
I'm at 112 already and most americans go to work now
and I've already capped yesterday--
 
@Morwenn Right. I should search for "burnt pizza" and see how many times I've burnt mine
@Vogel612 Well, if you need, I can try to help
 
that's called voting fraud, you know?
 
No
I will only vote if and only if it is worthy the vote.
And I would only vote 2-3 things
That isn't vote fraud
Specially if I see something that needs a comment and drop one there
And get an explanation
That is even less fraudy
 
0
Q: How to avoid character redundancy during user inputting the charcter?

Sivakumar TadisettiI have been writing the code to avoid character redundancy during user inputting the character My Logic is : if user has given input 'f' then i will check the 'f' position in alpha[] array and i will increment the same position in ccount[] array by 1 if user again e...

 
11:29 AM
@CaptainObvious The plain English part on that one is pretty hard to follow...
it's just a big block of text like this with no white space so it's hard to tell where a statement ends and another begins or if it's meant to be one big blob if everything goes together or else if those should be bullet points
 
@Phrancis Agreed.
Thank God it's broken, then I can just close it.
Otherwise I would have suggested closing it as Unclear.
@Phrancis oh, there's white space, just no punctuation.
 
1
Q: Legacy application unreachable code

Nenad BulatovicI am debugging one legacy J2EE application I and think I found some dead code and some redundant condition checks. Please give me your thoughts on my observations i.e. if they are valid. Please note that I am not permitted to rewrite this block, only to fix something if wrong or redundant. ... e...

 
@serigol No, it doesn't "go as an answer". Answer should an answer. OP wasn't asking about possible improvements, this is not a Code Review. — Mateusz Grzejek 7 secs ago
 
11:54 AM
Just want to repost a very long, very complete SO answer I'm quite proud of. I posted it last night after realizing the year-old answers to the year-old question were actually missing some important information and this particular question is regularly linked to (and used as a duplicate target):
5
A: Swift: Class does not implement its superclass's required members

nhgrifThere are two absolutely crucial pieces of Swift-specific information that are missing from the existing answers which I think help clear this up completely. If a protocol specifies an initializer as a required method, that initializer must be marked using Swift's required keyword. Swift has a ...

Also... if your familiar with OOP, the answer may be interesting in-and-of itself.
2
 
12:20 PM
2
Q: Is there a guide or checklist for doing code reviews?

Nessie SalantI've searched a little bit on the net to find a good guide on submitting and reviewing code reviews for my team. Any help is appreciated.

 
@StackOverflow how did that have positive two votes, lol
 
0
Q: Performance Optimisation: Matching between files and a VERY long list of filenames

ZakPurpose of the Macro: Given a folder typically containing ~250,000 small (20-100kb) files in HTML format (they open as single-sheet workbooks in excel) and a list of ~ 1 Million Filenames, open all the files that match the list and Do Stuff. Optimisation Parameters: It works, but will typically ...

 
@StackOverflow His blog is so hard to read
 
yeah
I opened it and saw abbreviations and poor English so closed it
 
I downvoted solely on: You’ll always find somebody who knows better.
For most, sure, but as a principle, no
 
12:34 PM
It's true though.
But it's also the least helpful advice there.
 
Let the reviewers drive the review.
The reviewers and their comments must drive a review. If developers are allowed to lead reviews of their own work, other reviewers might miss problems.
The first point is basically the first half of the second point
 
I think we should review his comment
 
Monking
 
12:49 PM
Greetings
 
@nhgrif I'm not a swift guy (at all), but how exactly does this apply to OOP in general?
 
@EBrown There's OOP in it.
 
0
A: In Swift, what does it mean for protocol to inherit from class keyword?

nhgrifThe gist of Starscream's answer is correct, but it misses the why which I think is important here. It comes down to ARC and memory management. Swift is a language of reference types and value types. Classes are value types, while everything else is a reference type. Effectively, we're not rea...

@EBrown The interesting Swift concept of not inheriting init methods.
 
@Quill I usually wait to recommend deletion on LQ answers. at least longer than an hour
 
@Malachi Okay
 
12:54 PM
@nhgrif I'm still not exactly sure on how those rules apply though, are you saying Swift doesn't inherit any init methods?
 
@Hosch250 what browser are you using? are you using TamperMonkey or GreaseMonkey?
 
Did you read my answer and you're still confused?
 
Well I'm down to the last block ("Ultimately...").
 
@Malachi I think he said IceDragon the other day
 
I'll re-read it in a moment, I might have missed something. (It's only 0854 here.)
So Swift, basically, requires that all objects be fully-initialized by the init methods?
 
12:56 PM
he should be able to use GreaseMonkey with that one .... Nevermind
 
0
Q: TicTacToe minimax algorithm returns unexpected results in 4x4 games

Omar SharakiIn my method newminimax499 I have a minimax algorithm that utilizes memoization and alpha beta pruning. The method works normally for 3x3 games, however when I play 4x4 games I get strange, unexpected position choices for the computer. He still never loses, but he doesn't seem to be playing to wi...

 
@EBrown That's part of the takeaway from my answer, yes.
 
@nhgrif That makes more sense, now.
 
You can inherit init methods.
 
I've never used Swift before in my life, so I apologize for the confusion.
 
12:57 PM
If you implement 0 init methods, you're inheriting all of the superclass's init methods.
 
But if you implement even one then you inherit none?
 
If you implement even one, then you inherit none of the super class's designated init methods.
You can however inherit a convenience init if the super class's convenience init points to an init you happened to implement in the subclass.
 
I guess I'm not sure what a "convenience" init is.
 
I'll show you, hang on
convenience init() {
    self.init(foo: "Foo")
}
A convenience init must call another init in the class. It must delegate laterally.
 
It seems I misunderstood the purpose of the site. What do you recommend? — Omar Sharaki 19 secs ago
 
1:01 PM
Ah, that makes sense. Would that be similar to having an init with parameter foo that has a default of "Foo"?
 
I would recommend deletion, but once your code works and you solved your bug, you could bring it on back and we can help you to improve it. — Quill 12 secs ago
 
Okay so we have this class:
class SuperClass {
    var foo: String
    init(foo: String) {
        self.foo = foo
    }

    convenience init() {
        self.init(foo: "Foo")
    }
}
This makes sense and is normal, right?
 
Yes.
 
now we do this class:
class BarClass: SuperClass {
    var bar: String
    init(foo: String, bar: String) {
        self.bar = bar
        super.init(foo: foo)
    }
}
We are not inheriting any init methods from the super class
We can't call one of the super class init methods and get BarClass into a valid state, because the super class constructors would leave bar nil, and bar is not an optional, so nil isn't a valid state for the object.
but... if we do this:
class ChildClass: SuperClass {
    var bar: String
    init(foo: String, bar: String) {
        self.bar = bar
        super.init(foo: foo)
    }

    convenience override init(foo: String) {
        self.init(foo: foo, bar: "Bar")
    }
}
Notice how we've implemented and overridden init(foo:)?
 
Yes, but we marked it as convenience as well.
 
1:04 PM
@Hosch250 please submit an issue --> github.com/malachi26/ReviewQueueNotifier that way I can look into it when I get home. I don't want to install random browsers at work
 
Since the super class declared the convenience init init() which calls self.init(foo:) and then in the subclass we override the init that it was calling, then we can and do inherit init()
The super class init() now calls ChildClass's init(foo:), which in turn calls the ChildClass's init(foo:bar:), which in turn calls the super class's init(foo:)
 
Aha, that makes sense.
 
@Malachi is *V2.user.js the latest, or are they just about the same?
 
That we eventually get around to calling the super class's init(foo:) is actually irrelevant. It's just that we must make a call up to a super class's designated init. You can have multiple designated init methods.
 
So the super can call init methods in the child, if the child specifically implements them?
 
1:06 PM
No, that's not the right way to think about it.
The child can inherit convenience init methods if it implements the designated init that that convenience init points to
 
Ah, that makes even more sense.
 
Otherwise, that init simply doesn't exist for the child.
And Swift has specific rules for the order in which you call super.init or self.init
The gist of it is this: Initialized, Delegate, Overwrite.
 
So by the child class turning init(foo: String) into a convenience init, it's now considered a valid override of the SuperClass init(foo: String), and is considered to completely initialize the class?
 
Before you can call super, you must initialize any values that your class added.
@EBrown Yes, because convenience init methods must point to designated init methods and cannot point upward
 
Interesting, so it's similar to some of the logic of struct constructors in C#: you cannot leave any fields uninitialized.
 
1:09 PM
And designated init methods must call a super designated initializer and cannot call self.
 
@Quill that is development. I should change the name, huh?
 
And importantly, you cannot overwrite superclass properties until after you've delegated
 
So you have to call a super init method before you can even begin to change those properties?
 
@Quill I changed the name
 
@Malachi I was thinking about doing a few pull requests with improvements here and there, but if it's dev version I'll wait until a stable release
 
1:10 PM
You have to call a super init before you can even refer to self
 
I see, because at that point self.foo is not really initialized.
 
@Quill ReviewQueueNotification.js is stable as well as ReviewQueueNotification.user.js
 
self doesn't even exist until we've delegated all the way to the top of the inheritance tree and initialized every variable
 
Until the super.init(foo: foo) initializes self.foo, it cannot be referenced.
Now I assume, that if we were to extend this further, each init method would have to call an applicable super.init method if it inherited a class?
class ChildChildClass: ChildClass {
    var fooBar: String
    init(foo: String, bar: String, fooBar: String) {
        self.fooBar = fooBar
        super.init(foo: foo, bar: bar)
    }
}
Something like that would be completely valid?
 
Right.
It's not that I can't touch the variable before I delegate upward
self simply doesn't exist until the call to super, I mean, not really.
Only insomuch as being able to refer to the properties that the class introduced
but you can't even call any methods
 
1:15 PM
there's code review, isn't it? — Andrew Tobilko 29 secs ago
 
class ChildChildClass: ChildClass {
    var fooBar: String
    init(foo: String, bar: String, fooBar: String) {
        self.fooBar = fooBar
        super.init(foo: foo, bar: bar)
    }

    convenience override init(foo: String, bar: String) {
        self.init(foo: foo, bar: bar, fooBar: "FooBar")
    }

    convenience override init(foo: String) {
        self.init(foo: foo, bar: "Bar", fooBar: "FooBar")
    }
}
Is that still valid?
I assume then you could initialize it with init(foo: "Foo") just like SuperClass?
 
@CaptainObvious RBA
@Duga Related to above
 
And, another note, would the , fooBar: "FooBar" bit be necessary in the init(foo: String) method? I assume not, as then it would call the other convenience method which would initialize fooBar properly.
 
@AndrewTobilko, the author is having unexpected results, meaning that the code does not function as expected, or is broken code, which, is strictly off-topic on Code Review. — Quill 15 secs ago
 
Well, before you added the third method it would have already inherited that from ChildClass and in turn also inherited the zero argument one from ChildClass
 
1:19 PM
So you don't need the third method in ChildChildClass?
 
Also, the override keyword is only used if you are overriding a designated init, and not a convenience init
 
No, you wouldn't, would you.
Because ChildClass init(foo: String) calls self.init(foo: foo, bar: "Bar"). So that would call the convenience override init(foo: String, bar: String), right?
Which explains why Swift allows you to inherit convenience methods.
 
this is pretty cool stuff, I must admit
 
I mean, chances are I'll never use Swift in my life, but if I do at least this hopefully won't surprise me. :)
 
it doesn't seem to work in FireFox?
 
1:26 PM
@EBrown Oh well, the way Microsoft are bending over backwards for Apple users/devs these days, it may not be too long till some kind of derivative hits VS
 
@Quill Indeed.
 
class A {
    var a: String
    init(a: String) {
        self.a = a
    }

    convenience init() {
        self.init(a: "A")
    }
}

class B: A {
    var b: String
    init(a: String, b: String) {
        self.b = b
        super.init(a: a)
    }

    convenience override init(a: String) {
        self.init(a: a, b: "B")
    }
}

class C: B {
    var c: String
    init(a: String, b: String, c: String) {
        self.c = c
        super.init(a: a, b: b)
    }

    convenience override init(a: String, b: String) {
 
@nhgrif Now I assume, that let c1 = C() calls the init() method on A, which calls the init(a: String) method on B, which calls the init(a: String, b: String) method on C?
 
not exactly.
A's init() is a convenience init which calls init(a:)
B implements the same init, init(a:) and therefore inherits init() from A.
B also implements init(a:b:). B's init(a:) is a convenience init pointing to init(a:b:).
C implements that init(a:b:) (as a convenience init) and therefore inherit's B's init(a:) because it implements the init that B's convenience init, init(a:) points too.
And because C is inheriting init(a:), it is also implementing the init that B's inherited convenience init() points to, and therefore, C is inheriting init() from B.
 
So if C never implemented convenience override init(a: String, b: String), then it would never have the init(), init(a: String) or init(a: String, b: String) initializers?
 
1:33 PM
Right.
 
It would only have init(a: String, b: String, c: String)?
 
It would just have init(a:b:c:)
Exactly.
 
That makes sense.
So Swift actually does quite a bit of checking to make sure that the initializer calls will traverse all the way down the pipeline, correctly.
And if the pipeline is broken (at any place) then any initializers up to that point are unavailable.
My reasoning is correct?
 
If you want advice on how to improve working code then try the Code Review site. Strictly speaking, SO is only for broken code. — ChipsLetten 42 secs ago
 
Yep.
 
1:38 PM
0
Q: Using ng-show and ng-hide within a ng-repeat

Sean ParsonsI created a login service which holds a boolean based on if a user is logged in or not. angular.module('deafApp') .service('LoginService', function(){ var $this = this; $this.loggedIn = false; }); And in my inside my login controller I attach the LoginService to a...

 
@CaptainObvious And that makes 500 edits
 
@nhgrif Reading some of the comments on the other answers to that question, most of them are explained by your answer...lol
 
yeah, exactly
 
Although, it completely makes sense why Swift would work that way.
 
We had like a 3 hour discussion about this at work yesterday, me and a coworker
both of us realized we didn't fully understand how init works in Swift
 
1:52 PM
I wish I had people at work to talk to about concepts like that.
 
but now we do...
 
I'm the only good programmer in this company.
 
... and now we're adding as an interview question "Explain how init inheritance works in Swift."
 
Our Sys/Net Admin knows how to programme, but he's not good at it by any means.
And he doesn't understand a lot of the complex topics I use.
(LINQ, Optional Parameters, etc.)
 
@Quill congrats
 
1:54 PM
@Heslacher Thanks :-)
 
Ew, @Quill... the monospace code blocks looks ugly there... I intentionally leave those out of the error messages (in Xcode, they aren't formatted differently from the rest of the error message either)
 
@nhgrif Pull them then
 
I'm not going to edit it again
 
0
Q: How to Eliminate an "unnecessary" Foreach Loop

Goldentoa11I'm using Bootstrap 3 to build a tab-panel component, based on information coming from the end-user. I don't like how there's a second foreach loop, but I don't know how else to print the HTML correctly. Given an array structured like this: [ { "title": "Title 1", "content":...

 
@EBrown I had the same thing at work, but with ternary statements -_-
 
We got some new guys recently though, so, hopefully a bit better
 
@Quill Well it's VB.NET so those are a bit easier, as they are an IIf thing.
I.e.: class = answered ? "green" : "red"; in C# is equivalent to VB.NET's class = IIf(answered, "green", "red").
(IIf being Inline-If.)
 
@EBrown content = (page.type == 'home' ? PageBuilder.BuildHomePage() : PageBuilder.BuildGenericPage); isn't really hard to understand
 
You can also use just If, which is probably closer to a real ternary.
If(answered, "green", "red")
 
Interesting.
Did not know that @nhgrif.
Adding that to my list of tricks. :)
 

« first day (838 days earlier)      last day (3181 days later) »