Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7076313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:17:00+00:00 2026-05-28T06:17:00+00:00

Consider the following code example: TempList.ForEach(Function(obj) obj.Deleted = True End Function) And this one:

  • 0

Consider the following code example:

    TempList.ForEach(Function(obj)
        obj.Deleted = True
    End Function)

And this one:

    TempList.ForEach(Function(obj) obj.Deleted = True)

I would expect the results to be the same, however the second code example does NOT change the objects in the list TempList.

This post is more to understand why…? Or at least get some help understanding why…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:17:00+00:00Added an answer on May 28, 2026 at 6:17 am

    It’s because you used Function instead of Sub. Since a Function returns a value, the compiler considers that the equals sign (=) is used as a comparison, not an assignment. If you change Function to Sub, the compiler would correctly consider the equals sign as an assignment:

    TempList.ForEach(Sub(obj) obj.Deleted = True)
    

    If you had a multiline lambda; you wouldn’t have had this problem:

    TempList.ForEach(Function(obj)
                         obj.Deleted = True
                         Return True
                     End Function)
    

    Obviously, for the ForEach method it makes no sense to use a Function because the return value wouldn’t be used, so you should use a Sub.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like different nested onmousedown events. For example, consider the following code: <div
Consider the following code: function Robot(weapon) { this.weapon = weapon; this.fire = function() {
Consider the following code: function Dog() { this.foo = function() {}; this.walk = function()
Consider the following code: (live example here ) $(function() { var wrapper = $(<div
Consider following SWT code example: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java?view=co How can I separate the inline defined class?
Consider the following code: $(a).attr(disabled, disabled); In IE and FF, this will make anchors
For example, consider the following code (in a model): scope :popular, where(views >= 250
Consider the following example code: http://code.google.com/apis/maps/documentation/javascript/examples/streetview-simple.html I can do scrollwheel: false on a mapOptions
Consider the following example code: class Foo { }; class Bar : public Foo
Consider the following example code class A: def __init__(self, i): self.i = i print("Initializing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.