Tech Tidbits (Vol. IV): new Date(you, me);

This comic walks through a few concepts:

Java

If you take AP Computer Science, you would have some familiarity with the object-oriented language Java. In this case, the protagonist is referring to creating a Date object, which simply holds a calendar date (like 11/12/2021). The syntax the protagonist uses creates a new variable (called “us”) of type Date, passing “you” and “me” as parameters (which, for the record, are not actual parameters for the Date object).

       Date us = new Date(you, me);

C++

In response, the girl replies with some C++ code

       bool goOnDate;

       cin >> goOnDate;

       cout << goOnDate;

       // true

The first line of code establishes a boolean variable called goOnDate. All this means is that goOnDate is a variable—sort of like x in a math equation—except it can only hold the values “true” or “false.” The next two lines take input and output. cin >> goOnDate; asks for the user to assign a value to the variable (either true or false), and cout << goOnDate; returns the value of the inputted variable. The double-slash is a comment, so it has no real effect on the block of code. Occasionally, programmers will use the comments to write the expected output. In this case, it reads “true,” so the girl agrees to go on the date.

LeetCode

LeetCode is a popular platform for programming problems and helping programmers prepare for interviews.