I'm doing my first application on Android, it consists of a &quot;To do Task&quot;. My problem is when I want to check the text of my TextView, which contains the date (array of strings), with the date on which the information is saved. This if I do to run the check never works. // Write date in Array SimpleDateFormat formatdate = new SimpleDateFormat(&quot;dd-MM-yyyy&quot;, Locale.getDefault()); Calendar calendar = new GregorianCalendar(); String[] date = new String[6]; for(int i = 0; i &lt; 6;i++){     calendar.add(Calendar.DATE  , 1);     date[i] = formatdate.format(calendar.getTime()); }  tvdate2.setText(date[0]); // 16-03-2021 ...  // When clicking on the button, it checks and then displays the corresponding information btn2.setOnClickListener(new View.OnClickListener() {     public void onClick(View view) {                         String test =&quot;16-03-2021&quot;;         if (tvdate2.getText().toString() == test){             testing.setText(&quot;It works!!&quot;);         }                     } });
I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.  Is == bad? When should it and should it not be used? What's the difference?
I am trying to create buffers around the Hurricane Sandy path I created in QGIS (points are lat/long).   I have both points from each day she was tracted and the line I created from it with Points2One.   When I go to make buffers around either the line or the points, the buffer takes up the whole screen. Its all just one color.   I have made buffers before but from data I did not create.   Right now all of my projections are set to WGS 84 EPSG 4326. Best way to return multiple values from a function? The canonical way to return multiple values in languages that support it is often . Option: Using a tuple Consider this trivial example: def f(x):   y0 = x + 1   y1 = x * 3   y2 = y0 ** y3   return (y0, y1, y2)  However, this quickly gets problematic as the number of values returned increases. What if you want to return four or five values? Sure, you could keep tupling them, but it gets easy to forget which value is where. It's also rather ugly to unpack them wherever you want to receive them. Option: Using a dictionary The next logical step seems to be to introduce some sort of 'record notation'. In Python, the obvious way to do this is by means of a dict. Consider the following: def g(x):   y0 = x + 1   y1 = x * 3   y2 = y0 ** y3   return {'y0': y0, 'y1': y1 ,'y2': y2}  (Just to be clear, y0, y1, and y2 are just meant as abstract identifiers. As pointed out, in practice you'd use meaningful identifiers.) Now, we have a mechanism whereby we can project out a particular member of the returned object. For example, result['y0']  Option: Using a class However, there is another option. We could instead return a specialized structure. I've framed this in the context of Python, but I'm sure it applies to other languages as well. Indeed, if you were working in C this might very well be your only option. Here goes: class ReturnValue:   def __init__(self, y0, y1, y2):      self.y0 = y0      self.y1 = y1      self.y2 = y2  def g(x):   y0 = x + 1   y1 = x * 3   y2 = y0 ** y3   return ReturnValue(y0, y1, y2)  In Python the previous two are perhaps very similar in terms of plumbing - after all { y0, y1, y2 } just end up being entries in the internal __dict__ of the ReturnValue. There is one additional feature provided by Python though for tiny objects, the __slots__ attribute. The class could be expressed as: class ReturnValue(object):   __slots__ = [&quot;y0&quot;, &quot;y1&quot;, &quot;y2&quot;]   def __init__(self, y0, y1, y2):      self.y0 = y0      self.y1 = y1      self.y2 = y2  From the :  The __slots__ declaration takes a sequence of instance variables and reserves just enough space in each instance to hold a value for each variable. Space is saved because __dict__ is not created for each instance.  Option: Using a  (Python 3.7+) Using Python 3.7's new dataclasses, return a class with automatically added special methods, typing and other useful tools: @dataclass class Returnvalue:     y0: int     y1: float     y3: int  def total_cost(x):     y0 = x + 1     y1 = x * 3     y2 = y0 ** y3     return ReturnValue(y0, y1, y2)  Option: Using a list Another suggestion which I'd overlooked comes from Bill the Lizard: def h(x):   result = [x + 1]   result.append(x * 3)   result.append(y0 ** y3)   return result  This is my least favorite method though. I suppose I'm tainted by exposure to Haskell, but the idea of mixed-type lists has always felt uncomfortable to me. In this particular example the list is -not- mixed type, but it conceivably could be. A list used in this way really doesn't gain anything with respect to the tuple as far as I can tell. The only real difference between lists and tuples in Python is that lists are , whereas tuples are not. I personally tend to carry over the conventions from functional programming: use lists for any number of elements of the same type, and tuples for a fixed number of elements of predetermined types. Question After the lengthy preamble, comes the inevitable question. Which method (do you think) is best? My case here is that I was writing something for school, and my teacher explained an error which I really can't see. She referred to articles about &quot;dangling participles&quot;, which was previously unknown to me. I find it hard to relate the examples I've found about it to my situation. So this is a text I've written and the bold part is where the problem arises: (You could read only the bold part if you please)  Wandering, and lost in his thoughts, there is a deep despair occupying the mind of this man. He is barely aware of his surroundings, except for those few moments when the loud blissful voices break through the protective barriers, developed by his immense sadness and grave frustration, into his mind. ”How can they all possibly be so happy?” he thinks to himself. Staring blindly, with his head low, as he walks in a slow pace, whispering ”Mary, Mary, my Mary,” over and over again. Yesterday was her funeral. She had passed away from a severe type of cancer, at a relatively young age. It was his wife. They had been together since high school and were greatly attached to each other. Having spent nearly half his life by her side, we cannot but imagine his grief. Indeed, he could hardly picture a life without her. So, alone he roams in the midst of all the seemingly incessant cheering and noises, drowned by his sorrow.  Her comments on that part was:  we is slightly out of place here – see my comment below These few sentences are about him and his emotions, so ‘we’ seems out of place. If the sentence starts: ‘Having spent nearly half his life by her side’, the reader expects it to continue: ‘he’. After all we have not spent half our lives by her side.  Is she right? If so, could anyone try to explain why? Why does cycle rendering only use one core from an AMD GPU? Does the sign of $\Delta x$ matter in this time dilation calculation? There is a (very minor) typo in the Close Votes review audit failure message. The message is presented as follows:  STOP! Look and Listen. This was an audit, designed to see if you were paying attention. You didn't pass. There are no major problems with this question. You should click Leave Open, or make minor corrections via Edit. Don't worry, we've already handled this post appropriately – but please take a minute to look it over closely, keeping in mind the guidance above.;  The ; at the end is a typo and is in the actual message that was displayed. Behaviour of return statement in catch and finally How do I extend a List in Dart? Are there other governments in The Hunger Games world? We know that Panem exists in a post-apocalyptic North America but are there other established governments on other continents? Getting the Volume of an Uneven Mesh Runtime error : ERROR 000358: Invalid expression using SelectLayerByAttribute in ArcPy? I cannot for the life of me persuade SelectLayerByAttribute to work (I need to automate this for a complex script).  Working in ArcMap's python console on already loaded shapefile, the format below:  import arcpy from arcpy import env arcpy.env.workspace = r"C:/Users/.../working" arcpy.SelectLayerByAttribute_management("layer", "NEW_SELECTION", " 'ATTRIBUTE' = 'Criterion' ")   results in error:     Runtime error : ERROR 000358:   Invalid expression Failed to execute (SelectLayerByAttribute).   An alternative method:  import arcgisscripting import arcpy gp = arcgisscripting.create(9.3) gp.workspace = "C://...//working" sFile = "C://...//working//shapefile.shp" lyr = "layer" gp.makefeatureLayer_management(sFile, lyr) gp.toolbox = "management" gp.SelectLayerByAttribute("layer", "NEW_SELECTION", " 'ATTRIBUTE' = 'Criterion' ")   .. selects everything, including features that don't meet the criterion!  Does anyone have any idea what's going wrong?  I've read some pages on , but found no solution that works here. The working directory is correct. The attribute field and criterion are correctly specified (case sensitive etc), etc. Its very confusing. The origin of my question arose from a problem: Let $q: X \to Y$ and $r: Y \to Z$ be covering maps, let $p= r \circ q$. Show that if $r^{-1}(z)$ is finite for each $z \in Z$, then $p$ is a covering map.  I am just wondering is there an easy counter example to show the necessary of "inverse image of every point is finite" condition?  I have already checked Hatcher's book (the wedged circle example) but I wonder is there a less complex and more obvious example?  I tried to construct a counter example by composition of a covering map from $R_+$ to $S^1$ with $R$ in the middle, but I failed due to I can't find a covering map from $R^+$ to $R$ which does the job. Equation left margin I have equations inside an environment which has a larger left-margin than the main text (analogous to an enumerate/itemize environment, implemented with the changepage package's adjustwidth environment). Just as equations in enumerate/itemize behave, the equations are centered with respect to the entire text, rather than just the width of the container environment. I want the latter behavior.  I'm trying to accomplish this by wrapping all display-math in minipages. Namely, I'm modifying the mathdisplay environment in amsmath.sty as follows:  \makeatletter \let\oldmd\mathdisplay \def\mathdisplay#1{%   \newline   \begin{minipage}{\textwidth-\@totalleftmargin}%     \oldmd{#1}% } \let\oldendmd\endmathdisplay \def\endmathdisplay#1{%   \oldendmd{#1}%   \end{minipage} } \makeatother   This is almost working, but there are some issues with spacing which I don't understand how to fix. Here's how the the normal \[ ... \] and numbered \begin{equation} ... \end{equation} look with the above modification:      My main confusion is why the numbered version is behaving so differently from the unnumbered. But all in all I want to fix this so that the spacing above and below is even as it usually is. Any help is appreciated, thanks.  Edit: Here's a compilable example:  \documentclass{amsart}  \usepackage{lipsum} \usepackage{calc} \usepackage{changepage}  \makeatletter \let\oldmd\mathdisplay \def\mathdisplay#1{%   \newline   \begin{minipage}{\textwidth-\@totalleftmargin}%     \oldmd{#1}% } \let\oldendmd\endmathdisplay \def\endmathdisplay#1{%   \oldendmd{#1}%   \end{minipage} } \makeatother  \setlength{\parindent}{0pt}  \begin{document}  \lipsum[1]  \begin{adjustwidth}{20pt}{} \lipsum[2] \[ x \mapsto \hom(-,x) \]  \lipsum[3] \begin{equation}   y \mapsto \hom(y,-) \end{equation} \lipsum[4] \end{adjustwidth}  \lipsum[5]  \end{document} Why "Dark Energy" is called energy instead of force? The overly simplified explanation I'm giving myself right now is  causes the opposite of what gravity does, that's why the universe is expanding. Now where gravity is a force, why dark energy is "energy"? Why it's not called "Dark Force" instead? I think I must be missing something here. What we've gelost — why doesn't English use the prefix "ge-"? The Germanic languages that I'm familiar with all use a prefix similar to ge- on past participles:  German: Ich habe mir den Fuß gebrochen. Dutch: Ik heb mijn voet gebroken.  But English doesn't do this at all:  English: I've broken my foot.  Where did this prefix come from? Did English ever have the ge- past participle prefix? If so, why was it lost? How should I phrase a question that must be answered with an ordinal number (e.g., the third prime)? I want to make a question having an answer as follows:     5 is the third prime number.   The bold part is the answer. How to phrase the question? How do I separate hydraulic disc brake pads after pulling the brake while the wheel is off? "He saw it stop and his son get out" I have been reading Men With Brooms for a few days. I read a sentence which did not make any sense to me, so I landed here to get some help on it. I have pasted the sentence from the novel. Please go through it and let me know your valuable feedback on it.  An excerpt from the novel (Men With Brooms: A Sweeping Epic, paperback 2002, a novelization by Diane Baker Mason):     Gordon was about to walk away from the Impala when he saw it stop and his son get out. So it was real the boy had come.   As per my opinion it should have been:     Gordon was about to walk away from the Impala when he saw it stopped and his son got out. So it was real the boy had come.   I have two questions here:   Why did the writer use stop and get instead of stopped and got? As she is telling us a story which happened in the past. Let's say the writer is telling us her mind's situation and she used the present tense for it but why did she use stop and get instead of stops and gets? Everyone I speak to says that a 50mm lens is the best and beats them all as an all-rounder. I was wondering whether to get myself a decent, fast 50mm as well. However I'm still not 100% sure whether I really need such a lens.  I use a Pentax K10D and mainly shoot people (kids, portraits, some street shots). The lens I love and use most is the DA 70mm f/2.4 Limited. I often also use a DA 40mm f/2.8 Limited. They are great little lenses that produce very high quality images but they could be a bit faster.  Is is worth spending 400 quid on a Sigma 50mm f/1.4 in my situation? It seems like a good compromise between the 40mm and 70mm and much faster (in fact, 2 f-stops faster than the DA 70mm f/2.8!). On the other hand would the lens be sufficiently different from my current lenses? $$\frac{1}{n+1}&lt; \log(1+ 1/n)$$  Any ideas? I tried estimating the difference between $1/n$ and the logarithm and comparing with $1/n-1/(n+1)$ but I miserably failed.