Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by jpierre88 · Apr 18, 2016 at 06:18 PM · declarationlambda

Unexpected symbol `=>' in class, struct, or interface member declaration

I've came across a script written by a different author. I tried to implement it to my scene but received this error:

"Unexpected symbol `=>' in class, struct, or interface member declaration"

I've tried to look into lambda syntax but still confused on how it works and how to get rid of this error message. Here's the snippets

 public IEnumerable<object> Description => ((IEnumerable<object>) this.description);
 public IEnumerable<CSGPolygon> Polygons => this.root.AllPolygons;
 public BSP Clone() => new BSP(this.root.Clone(), this.Bounds, this.description, this._createDescription);

What am I missing?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by tanoshimi · Apr 18, 2016 at 07:21 PM

Personally not a fan of lambdas, but I think your syntax is missing the declaration of the argument types. Seeing as you don't appear to be passing any arguments, however, this would just be empty parentheses (like those that follow the signature of a regular method signature - void Start(), etc.):

 public IEnumerable<object> Description = () => ((IEnumerable<object>) this.description);
 public IEnumerable<CSGPolygon> Polygons = () => this.root.AllPolygons;
 public BSP Clone() = () => new BSP(this.root.Clone(), this.Bounds, this.description, this._createDescription);

I might be completely wrong though!

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jpierre88 · Apr 18, 2016 at 07:26 PM 0
Share

I received this error:

Unexpected symbol `=' in class, struct, or interface member declaration

Is there a way to rewrite to not use lambdas?

avatar image tanoshimi jpierre88 · Apr 18, 2016 at 07:36 PM 0
Share

Oh yes, absolutely. Lambdas don't provide any additional functionality - they are "syntactic sugar" - which some people think makes code more concise, and therefore improves it. Personally, I find them awkward to read and avoid them, hence why I'm clutching at straws solving your problem.

What line number is it that's throwing the error? I've just noticed that your third declaration has parentheses as if it were a method, which I'm certainly not familiar with - should it not be?:

public BSP Clone = () => new BSP(this.root.Clone(), this.Bounds, this.description, this._createDescription);

avatar image jpierre88 tanoshimi · Apr 18, 2016 at 08:06 PM 0
Share

Thumbs up for that one. I've started going through and adjust the code until I reached this one that looks like a method declaration:

 public static bool IsDegenerateSet(IEnumerable<CSGVertex> set) => 
             ((from a in set
                 group a by a.Position into a
                 select a.First<CSGVertex>()).Count<CSGVertex>() < 3);


It throws the same error. I wonder if its the same solution as above?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

40 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UnityEditor GenericMenu - Problem with 'AddItem' in Foreach Loop 1 Answer

Why can't "int y = 0" be a statement? 0 Answers

Trigger events from different sources 0 Answers

CS1023 An embedded statement may not be a declaration or labeled statement help 1 Answer

How to return a value from a anonymous function?, 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges