« first day (3617 days earlier)      last day (1335 days later) » 
00:00 - 14:0014:00 - 23:00

2:00 PM
@Hozuki Other than enumerating over the query variable using a foreach statement. Is there any other way to enumerate over the query variable, and return a sequence?
 
@BlackPanther Anything that uses the IEnumerable.GetEnumerator() function. A foreach does that, but so does a lot of other stuff, like .ToList().
 
@Hozuki Of course, I forgot about ToList(), ToArray() etc.
 
@DuckLing I think <CopyLocal> or something in the csproj
Set a reference to copylocal and see what changes
 
thanks Squirtle
I just realised it won't help me
 
2:03 PM
i need to load a user chrome profile via docker selenium container
so the profile has to be in the container filesystem
not locally where the code runs
 
Get yourself some Cypress
Mostly because it's not Java. I have no idea about your use case.
 
i think selenium will do just right:)
 
@BlackPanther .Single() .First() .Any() .Aggregate() etc
 
user12960916
Could someone help clarify this for me? If you have this line of code Button newButton; and newButton = new Button(); on 2 seperate lines of code, the first line declares a button variable which is null and the second line assigns that variable to an actual created button. But I'm not sure if the button still stays null even after you assign it to an actual created button
 
quack quack
says the duck
dont mind me
 
2:13 PM
@csscoder there is no null
 
user12960916
do you mean after you assign it to the actual button or no null at all?
 
no null at all
@Wietbot evalcsharp
void Run() {
    String test;
    Console.WriteLine(test);
}
 
null
 
-_-
 
user12960916
but if the 2 lines of code are separate isnt it null when the variable is declared?
 
2:15 PM
Microsoft.CodeAnalysis.Scripting.CompilationErrorException((4,23): error CS0165: Use of unassigned local variable 'test')
 
^
when the variable is declared, it is... undefined
it is not assigned yet
the compiler will prevent you from using it
if it were null, the snippet above would work
but it threw a compiler error
the first snippet is a bit special and is not normal C#, but the edited one is normal C#
 
user12960916
i thought in c# everything like string int double decimal is 0 if it isnt assigned to a value and objects are declared are null unless they are assigned something
 
only when they are fields/properties
when they are local variables, they must be assigned before usage
 
user12960916
so its undefined when Button newButton; is on the first line of code and still undefined if newButton = new Button(); is on the 2nd line of code?
 
after you assigned it, it will be whatever you assigned it to
in your case, the newly created button
 
user12960916
2:20 PM
got it thanks
 
@Wietlol @Wietlol Thanks. Would an extension method like the following also cause whatever object it is called on to be executed? In other words is anything executed in the statement below?
    var startingDeck =
    (from s in Suits().LogQuery("Suit Generation")
    from r in Ranks().LogQuery("Rank Generation")
    select new {Suit = s,
    Rank = r}).LogQuery("Starting Deck");
public static IEnumerable<T> LogQuery<T>(this IEnumerable<T> sequence, string tag) {
// File.AppendText creates a new file if the file doesn't exist.
using (var writer = File.AppendText("StartingDeckQuery.log"))
{
writer.WriteLine($"Executing Query {tag}");
}

return sequence;
}
 
... Make a postbin or something. That's unreadable.
 
@Hozuki Is it better now?
 
user12960916
ok kind of confused now @Wietlol, in visual studio i made a windows form wrote Button newButton; then did MessageBox.Show(newButton); and i dont get undefined i get name newbutton doesnt exist in current context
 
2:27 PM
@Feeds Shut It!
 
Just so u know, you didn't deserve it :P
 
nooooooooooooooooo
all hope is lost
 
Hans he was RO b4
 
@csscoder Don't listen to the Wiet, he dreams that everything is Kotlin
 
I just removved him for laughs and giggles
 
2:29 PM
@BlackPanther first... iDunno, second, nothing is executed
 
user12960916
so what he said was wrong?
 
oh right
 
Of course you can declare a variable without initializing it. It will just be its default value, so null for classes, 0 for numbers and false for bools,
 
@Squirrelintraining hehe
 
1 hour ago, by Squirrel in training
3 mins ago, by Wietlol
my Boolean says false
1 hour ago, by Squirrel in training
3 mins ago, by Wietlol
also, yes, it is Int32
 
2:30 PM
@csscoder rarely
 
@csscoder Everything he says is wrong.
 
user12960916
im so confused
 
I'm gone for an hour once and you guys let Wietlol troll people, haven't I trained you better?
 
what you have is just an issue of scoping
> doesnt exist in current context
has nothing to do with the initial value and stuff
 
user12960916
so he's a bot?
 
also, dont listen to Squirrelkiller, he is a maniac :D
can you share the code that gives you the error?
on a side note... wadda hek?
Wietbot cannot be a room owner due to limitations
but he was a room owner before...
 
@Wietbot evalcsharp
string str;
Console.WriteLine(str == null);
 
Result: null
Output:
True
 
^ that doesnt count
 
Computer says yes
It even capitalized True
 
2:33 PM
@Wietbot evalcsharp
void Run() {
    string str;
    Console.WriteLine(str == null);
}
Run()
 
Microsoft.CodeAnalysis.Scripting.CompilationErrorException((4,23): error CS0165: Use of unassigned local variable 'str')
 
@Squirrelkiller your snippet is not normal C#
 
user12960916
what's the buttons again to format code?
 
ctrl+k
 
in C# 8 (which Wietbot is using), there cannot be top level statements
 
user12960916
2:33 PM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace tester
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        Button newButton;
        MessageBox.Show(newButton);

    }
}
 
the scripting lib makes a werid thing from it
 
user12960916
i just wanted to see how you got undefined so i tried it myself but im just getting a tons of errors literally with just those 2 lines
 
@csscoder you are trying to put a statement in a class
 
There is no undefined value in C# though
 
MessageBox.Show(newButton); must be within a function
for example, inside Form1() { ... }
 
2:35 PM
Yup that's the actual problem
 
public Form1()
{
    InitializeComponents();
    MessageBox.Show(newButton);
}
however, in this case, it will probably be null
newButton in your case is a class field, not a local variable
class fields/properties have different behavior when not explicitly assigned
19 mins ago, by Wietlol
only when they are fields/properties
 
user12960916
it's not really in any code it's i just wanted to know the different of whether it would be null or undefined because i know for sure its not 0
 
user12960916
if the two lines are seperate
 
user12960916
so it IS null on the first line correct?
 
when you declare a class field/property, it will be the default value (aka default(T)), for classes, it would be null, for structs, it would be a mess
when you declare a local variable, it will be unassigned, being in a state where you cannot operate on it
if your snippet is
Button newButton;
newButton = new Button();
 
user12960916
2:40 PM
yep thats what it is
 
I would assume you are talking about a local variable
when your snippet is
 
@Squirrelintraining the cgi in that movie was so bad that the gif looks like a clip from clone wars
 
class Test {
    Button newButton;
    void Foo() {
        newButton = new Button();
    }
}
I would assume you are talking about a field/property
in the first snippet, newButton is initially unassigned,
in the second snippet, newButton is initially null,
 
user12960916
im still fairly new to c# so i dont know if im mixing this up but doesnt the 1st line in the 1st snippet (Button newButton) make a null reference variable? since reference variables have the name of a class in front and in this case its the button class?
 
@Freerey mimimi
 
2:44 PM
the variable is unassigned in the first snippet
there is a difference between
Button newButton;
and
Button newButton = null;
in the second snippet, there would not be any difference
 
yo yo yo
@Wietlol what's up with all the coded language
 
@Hozuki Is the reason that nothing is executed because Where(...), and Orderby(...) return an IEnumerable<T> interface object?
 
user12960916
3:01 PM
im still confused
 
user12960916
what's the difference? the snippet that i have is the first one you put
 
user12960916
Button newButton;
newButton = new Button();
 
user12960916
is what i have
 
@BlackPanther Yeah. Take a look at what an enumerator actually is. Check what methods it defines... GetEnumerator. Once you call that, you get an enumerator object. That object has Current and MoveNext(). That's how everything iterates over whatever the enumerator produces. If the GetEnumerator is never called, nothing is executed.
What a foreach is... is nothing more than a while loop calling MoveNext() and operating on Current.
So... these two are the same @BlackPanther:
var enumerator = enumerable.GetEnumerator();
while (enumerator.MoveNext()) Console.WriteLine(enumerator.Current);
Same as:
foreach (var current in enumerable) Console.WriteLine(current);
So... foreach is just compiler magic to make it simpler to write out such loops.
 
@Hozuki Thanks, the way that the Enumerable and Enumerator objects work behind the scenes is very interesting. I'm now sure that all methods that return IEnumerable<T> do deferred execution when they are called, even iterator methods.
 
3:06 PM
Well, you can't be sure, but everything in .NET usually does, yes! But I could write an enumerable that doesn't defer... it's pointless, but I could.
 
@Hozuki That's a really good simplification that I hadn't thought of.
 
Here's an example of me being a stupid idiot and making a non-deferred enumerable...
    class MyEnumerable<T> : IEnumerable<T>
    {
        private readonly List<T> _data;

        public MyEnumerable(IEnumerable<T> enumerable)
        {
            _data = enumerable.ToList();
        }

        public IEnumerator<T> GetEnumerator()
        {
            return _data.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
 
user12960916
hey @Hozuki, do you think you could help with a question?
 
Like I said, not usually what happens; but possible.
@csscoder No. I haven't the time, gotta go now.
 
@Hozuki What's missing in this example that stops the enumerable object from deferring execution? I mean it still has a GetEnumerator method which returns an Enumerator which is where all the magic performed by the MoveNext() method and Current property happen.
@Hozuki I look forward to your answer next time.
@Hozuki I think an enumerable that doesn't defer would be useful in the scenario given in this chapter. What do you think?
 
3:28 PM
@csscoder the difference is local variable vs class field
if you are certain that your case is the first snippet (local variables) then you cannot operate on the variable before it is assigned
it is that simple
the declaration just reserves memory to be used
in some runtimes, the value would be whatever the bits were left off when they were last used
 
@Wietlol If you stepped over both statements in a debugger, wouldn't the value of Button newButton show as null?
 
in some runtimes, the bits would be reset
@BlackPanther that depends on the debugger
 
Ok, I just thought that both:
Button newButton;
and
Button newButton = null;
Have the value null, the only difference being that the first is unassigned, and the second is assigned?
 
the first one is undefined
it is up to the runtime to determine what the value should be
 
@Wietlol Seriously? I actually need to test it in Visual Studio. I know that in JavaScript it would be undefined but I never knew that C# has that type.
 
3:34 PM
it is not a type
nor a value
it is a specification
Visual Studio would show either of the following
1: null
2: Nothing
(where "Nothing" could be different because it is just what they would choose how to represent it)
not sure what Visual Studio does
my debugger says "unassigned" (in grey) (so option 2)
 
I see, okay. Thanks.
I've tested it in Visual Studio Code's debugger:
Actually:
            List<int> a;
            Console.WriteLine();
            List<int> b = null;
And both a and b are null.
 
ah
 
I didn't want to create a Button class, so another reference type will do.
 
posted on September 10, 2020 by ericlippert

All right, we have our quad data structure, we know how to get and set individual elements, and we know how to display it. We’ve deduplicated it using memoization. How do we step it forward one tick? (Code for this … Continue reading →

 
3:46 PM
@Wietlol Why does List<int> a; not work in the following code, but List<int> b = null works, even though the debugger shows both variables are null?
List<int> a;
            Console.WriteLine();
            List<int> b = null;

            try {
                a = new List<int> {1, 2, 3};
                b = new List<int>{1, 2, 3};
            } catch (Exception) {

            }
            a.ForEach(a => Console.WriteLine(a));
            b.ForEach(b => Console.WriteLine());
The line a.ForEach(a => Console.WriteLine(a)); causes a compiler error.
 
4:02 PM
because a might still be unassigned
if the try threw an exception before initializing a, it would fall to the swallow catch and continue to do a ForEach on a variable that is not assigned
it would break your runtime
so, the compiler stops you
the debugger is not showing you all the information
 
4:14 PM
I see, but there is no attempt in the try block to access the variable a, so an exception would never be thrown before it is assigned a value. The null value is never used in this case. Does the debugger not consider this?
 
if new List() throws an exception (which I doubt), then a remains unassigned
the compiler doesnt give a shit if new List() can throw an exception or not
you made a swallow catch, and an assignment in the try, so it wont give you the guarantee that a is assigned
 
Also is there actually a null value in List<int> a;, or is that just the debugger equating a variable without an assigned value as null, i.e. the null the debugger shows for List<int> a isn't actually a null value?
 
could be either
but it is probably null
 
@Wietlol I see, that makes sense.
@Wietlol What is this term "swallow catch"?
 
a catch that hides the exceptions being thrown
 
4:23 PM
@Wietlol A catch that does nothing with an exception?
@Wietlol @Wietlol The reason I think the null the debugger shows for an unassigned variable such as List<int> a; is not actually a value is because in the following code there is a compiler error when you try to write a to the console. If a actually had a null value then the string null would be written to the console, surely?
Example:
            List<int> a;
            Console.WriteLine();
            List<int> b = null;
            Console.WriteLine(a);
 
it is a compiler error
even if it is null in the runtime, at which point, it would probably print null,
you cannot run it because the compiler wont let you
 
@Wietlol so:
List<int> b = null;
Console.WriteLine(b);
Won't work.
because it is a compiler error?
@Wietlol for me the following code writes an empty line to the console:
List<int> a = null;
List<int> b = null;
System.Console.WriteLine(a);
Console.WriteLine(b);
But the following causes a compiler error:
List<int> a;
List<int> b;
System.Console.WriteLine(a);
Console.WriteLine(b);
 
5:03 PM
Yeah, the compiler won't let you use a variable that never gets assigned to
 
5:18 PM
Or, at least, it'll try, because it almost always means you made a mistake somewhere that you should think about.
 
 
2 hours later…
6:54 PM
@BlackPanther In the constructor, I'm doing a ToList(), ensuring that the enumerable passed in is executed and saved as a list. Then calling GetEnumerator just gives you an enumerator for that list. Thus, the execution wasn't deferred -- it was executed as soon as the instance of MyEnumerable was made.
 
7:12 PM
Is this bad practice to pass a DI object into a call like this, _manufactureEndpoint is what I am asking about.
 Manufactures = new ObservableCollection<ManufactureMenuViewModel>(
                    (from mapItem in mapList
                     select new ManufactureMenuViewModel(mapItem, _manufactureEndpoint)).ToList());
 
 
2 hours later…
mr5
8:43 PM
@AvnerShahar-Kashtan I'm not sure if I'm just bored but I finish watching the entire video.
@juanvan in my previous projects, we don't instantiate ViewModels manually. It also goes through DI.
looks off to me when passing non-interface parameters in ctors of VMs also.
 
 
2 hours later…
10:46 PM
@mr5 trying to make a dynamic treeview
Ohh derp I can just make it a property on the baseclass
 
mr5
perhaps try to find other way to pass that non-interface parameter?
 
see if that works, I could just code it and skip the DI for now >_<
BaseClass has the IsSelected/IsExpanded properties, call into the common process to fill with lookupItems, load a dummyTreeViewItem if another node exists off this node.
Track the Parents for who's getting expanded.
 
00:00 - 14:0014:00 - 23:00

« first day (3617 days earlier)      last day (1335 days later) »